From 7c0bd41b6a7c7fcfef63d2175f4a0ee2e5bf51e6 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 14 Nov 2023 08:49:32 +0100 Subject: [PATCH] data/make_man.sh: replace getopt with getopts use of getopt is a bashism and it is also quite cumbersome as a side effect, long options are no longer options --- data/make_man.sh | 62 ++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/data/make_man.sh b/data/make_man.sh index 2f6764f9b..8be16aed1 100755 --- a/data/make_man.sh +++ b/data/make_man.sh @@ -124,9 +124,9 @@ hd_rum_transcode_man() { } usage() { - printf "Usage:\n\t$0 [-d|--debug|-h|--help|-k|--keep|-n] [uv|hd-rum-trancode|all]\nwhere\n" - printf "\t-d|--debug - print debug info\n" - printf "\t-k|--keep - keep generated AsciiDoc sources\n" + printf "Usage:\n\t%s [-d|-h|-k||-n] [uv|hd-rum-trancode|all]\nwhere\n" "$0" + printf "\t-d - print debug info\n" + printf "\t-k - keep generated AsciiDoc sources\n" printf "\t-n - do not generate manpages (can be useful with -k)\n" printf "\n" printf "\tname of man page - specify 'all' generate all manual pages\n" @@ -139,43 +139,27 @@ DRY_RUN= KEEP_FILES= VERBOSE= -TEMP=$(getopt -o 'dhkn' --long 'debug,help,keep' -n "$0" -- "$@") - -if [ $? -ne 0 ]; then - echo 'Terminating...' >&2 - exit 1 -fi - -# Note the quotes around "$TEMP": they are essential! -eval set -- "$TEMP" -unset TEMP - -while true; do - case "$1" in - '-d'|'--debug') - VERBOSE="-v" - set -x - ;; - '-h'|'--help') - usage - exit 0 - ;; - '-k'|'--keep') - KEEP_FILES=1 - ;; - '-n') - DRY_RUN=1 - ;; - '--') - shift - break - ;; - *) - echo 'Internal error!' >&2 - exit 1 - ;; +while getopts dhkn name; do + case $name in + d) + VERBOSE="-v" + set -x + ;; + h) + usage + exit 0 + ;; + k) + KEEP_FILES=1 + ;; + n) + DRY_RUN=1 + ;; + ?) + usage + exit 1 + ;; esac - shift done if [ $# -eq 0 ]; then