From ecce415e7132ba61cdd51969d80f96c8d71eb5a6 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Mon, 4 May 2020 19:38:52 +0530 Subject: [PATCH] upload.sh: Fix longoptions argument capturing * Fix https://github.com/labbots/google-drive-upload/issues/27#issuecomment-623447792 * Don't print full path in error messages --- upload.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/upload.sh b/upload.sh index 10b6c38..11ecfbc 100755 --- a/upload.sh +++ b/upload.sh @@ -438,7 +438,7 @@ setupArguments() { case "$OPTION" in # Parse longoptions # https://stackoverflow.com/questions/402377/using-getopts-to-process-long-and-short-command-line-options/28466267#28466267 -) - checkLongoptions() { [[ -z ${!OPTIND} ]] && printf '%s: --%s: option requires an argument\nTry '"%s -h/--help"' for more information.\n' "$0" "$OPTARG" "$0" && exit 1; } + checkLongoptions() { [[ -n ${!OPTIND} ]] && printf '%s: --%s: option requires an argument\nTry '"%s -h/--help"' for more information.\n' "${0##*/}" "$OPTARG" "${0##*/}" && exit 1 || :; } case "$OPTARG" in help) usage @@ -510,7 +510,7 @@ setupArguments() { shorthelp ;; *) - printf '%s: --%s: Unknown option\nTry '"%s -h/--help"' for more information.\n' "$0" "$OPTARG" "$0" && exit 1 + printf '%s: --%s: Unknown option\nTry '"%s -h/--help"' for more information.\n' "${0##*/}" "$OPTARG" "${0##*/}" && exit 1 ;; esac ;; @@ -578,10 +578,10 @@ setupArguments() { DEBUG=true ;; :) - printf '%s: -%s: option requires an argument\nTry '"%s -h/--help"' for more information.\n' "$0" "$OPTARG" "$0" && exit 1 + printf '%s: -%s: option requires an argument\nTry '"%s -h/--help"' for more information.\n' "${0##*/}" "$OPTARG" "${0##*/}" && exit 1 ;; ?) - printf '%s: -%s: Unknown option\nTry '"%s -h/--help"' for more information.\n' "$0" "$OPTARG" "$0" && exit 1 + printf '%s: -%s: Unknown option\nTry '"%s -h/--help"' for more information.\n' "${0##*/}" "$OPTARG" "${0##*/}" && exit 1 ;; esac done