-
-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
After using argbash for quite a few arguments-heavy scripts and liking it a lot, I started to add it to most of my scripts to have a consistent help text and to be able to declare used environment variables.
During that I encountered the very minor issue, that argbash produces code that contains a shellcheck error when no arguments are defined.
A minimal example looks like this:
#!/usr/bin/env bash
# ARG_HELP([Does a thing])
# ARG_USE_ENV([SOME_ENV],[],[Contains important config])
# ARGBASH_GO()
# [ <-- needed because of Argbash
echo "${SOME_ENV}"
# ] <-- needed because of ArgbashThis produces the following argument parsing code:
parse_commandline()
{
while test $# -gt 0
do
_key="$1"
case "$_key" in
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
}Shellcheck complains about the shift in line 19, since it is unreachable.
I would expect argbash to realize this and omit the shift.
As I said I think this is a very minor issue.
If I get around to reading more m4, I might open another PR.
Metadata
Metadata
Assignees
Labels
No labels