diff --git a/README.md b/README.md index c5530c0..37812fe 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,6 @@ * bash 4+ -#### Optional - -* GNU getopt - - * Required to use long named switches, like --version or --help instead of -v and -h. - ### Install `sudo make install` diff --git a/burrow b/burrow index 0c9b4d8..67c3a77 100755 --- a/burrow +++ b/burrow @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC1117 version="v1.4.0" @@ -41,7 +42,6 @@ flag_noautoindent=0 # vars from args arg_options="hvd" -arg_longoptions="help,version,debug,noautoindent" arg_shortlist=0 arg_recipe=0 arg_phlog=0 @@ -75,9 +75,9 @@ COMMANDS: update-burrow Auto-update this application in its local folder OPTIONAL FLAGS: - -h, --help Show this help - -v, --version Show current version info - -d, --debug Debug mode + -h Show this help + -v Show current version info + -d Debug mode END } @@ -95,19 +95,7 @@ function check_coreutils { } function parse_input { - if getopt -T > /dev/null -eq 4; then - # GNU enhanced getopt is available - parsed=$(getopt \ - --options=$arg_options \ - --longoptions=$arg_longoptions \ - --name "$0" \ - -- "$@") - else - # Original getopt is available - parsed=$(getopt $arg_options "$@") - fi - - if [[ $? -ne 0 ]]; then + if ! parsed=$(getopt $arg_options "$@"); then die "Invalid input" 2 fi @@ -115,22 +103,18 @@ function parse_input { while true; do case "$1" in - -h|--help) + -h) flag_help=1 shift ;; - -v|--version) + -v) flag_version=1 shift ;; - -d|--debug) + -d) flag_debug=1 shift ;; - --noautoindent) - flag_noautoindent=1 - shift - ;; --) shift break @@ -574,11 +558,6 @@ function main { if [[ $arg_shortlist -gt 0 ]]; then out="phlog topic recipe rss edit-config create-config update-burrow update-git -v -h -d" - # include long options only if using gnu getopt - getopt -T > /dev/null - if [ $? -eq 4 ]; then - out="${out} --version --help --debug --noautointent" - fi die "${out}" 0 fi diff --git a/burrow.1 b/burrow.1 index ad26f34..b04e194 100644 --- a/burrow.1 +++ b/burrow.1 @@ -64,13 +64,13 @@ named or some variation of that name. .SH OPTIONS .TP -.B -v, --version +.B -v Display current version information. .TP -.B -d, --debug +.B -d Debug mode. .TP -.B -h, --help +.B -h Show the help. .SH FILES .I ~/.config/burrow/config