#!/bin/bash # Convert the exit code of certain apps to human friendly text. # The man page of the app is used for the conversion. # Find the supported apps by using option --help. # See also the man pages of the supported apps. echo2() { echo -e "$@" >&2; } Exit() { echo2 "$1"; exit "$2"; } Help() { cat </dev/null | grep -E "^[ ]+$exitcode[ ]+" | sed -E "s|^[ ]+$exitcode[ ]+||" ;; makepkg) # code and text on different, adjacent lines LANG=C MANWIDTH=300 man $app 2>/dev/null | grep -A2 -E "^[ ]+$exitcode$" | grep -v "^$" | tail -n +2 | sed -E "s|^[ ]+(.+\.)$|\1|" ;; esac } ExitCodeToString "$@"