Skip to content

Commit

Permalink
upload.sh: Fix longoptions argument capturing
Browse files Browse the repository at this point in the history
* Fix #27 (comment)

* Don't print full path in error messages
  • Loading branch information
Akianonymus committed May 4, 2020
1 parent bd63b2b commit ecce415
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
;;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ecce415

Please sign in to comment.