Change exit code when parser fails

This commit is contained in:
Sergei Eremenko 2019-11-19 22:19:30 +02:00
parent d16965de73
commit a16556e957

View file

@ -384,7 +384,7 @@ parse_args() {
# Show help if no argument is passed
if [ -z "$1" ]; then
usage 128
usage 2
fi
# Translate --gnu-long-options to -g (short options)
@ -401,7 +401,7 @@ parse_args() {
--version) args+=( -V ) ;;
--[0-9a-Z]*)
err "illegal option -- '$arg'"
usage 128
usage 2
;;
*) args+=("$arg")
esac
@ -426,10 +426,10 @@ parse_args() {
;;
h ) usage 0 ;;
: ) err "option requires an argument -- '-$OPTARG'"
usage 128
usage 2
;;
\?) err "illegal option -- '-$OPTARG'"
usage 128
usage 2
;;
esac
done
@ -439,7 +439,7 @@ parse_args() {
# Return an error if any positional parameters are found
if [ -n "$1" ]; then
err "illegal parameter -- '$1'"
usage 128
usage 2
fi
}