From f446f62eb968ba9479abcd1d2b00794340e78153 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 25 Sep 2017 15:09:31 -0400 Subject: chardiff: Better help text --- chardiff.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/chardiff.sh b/chardiff.sh index 6d629d2..4256d0c 100644 --- a/chardiff.sh +++ b/chardiff.sh @@ -32,6 +32,8 @@ wdiff_getopt() { eval set -- "$args" while true; do case "$1" in + -C|--copyright|-h|--help|-v|--version) + printf -- '%s' "$1"; return;; --) shift; break;; *) shift;; esac @@ -51,9 +53,31 @@ wdiff_getopt() { main() { # Normalize the arguments declare flags - flags="$(wdiff_getopt "$@")" || { wdiff --help >&2; return 1; } + if ! flags="$(wdiff_getopt "$@")"; then + printf "$(gettext 'Try `%s'\'' for my information.\n')" "${0##*/} --help" >&2 + return 2 + fi eval set -- "$flags" + case "$1" in + -C|--copyright) + wdiff --copyright + return + ;; + -h|--help) + printf "$(gettext 'chardiff - Compares characters in two files and report differences.\n')" + wdiff --help | sed -e 1d -e '/\s-d\b/d' -e /diff-input/d -e '/@gnu\.org/d' -e "s/wdiff/${0##*/}/g" + printf "$(gettext 'Report bugs to .\n')" + return 0 + ;; + -v|--version) + printf "$(gettext 'chardiff (thingutils chardiff) %s\n')" 0 + printf "$(gettext 'Using:\n')" + wdiff --version + return 0 + ;; + esac + # Run wdiff with our filters declare -a args=("$@") declare file2=${args[-1]}; unset args[-1] -- cgit v1.2.3-2-g168b