Tell which option is unknown.

This commit is contained in:
Alcaro 2016-01-29 00:48:11 +01:00
parent 219dd6c5d5
commit d86bda1ebd

View File

@ -48,7 +48,7 @@ EOF
opt_exists() # $opt is returned if exists in OPTS opt_exists() # $opt is returned if exists in OPTS
{ opt=$(echo "$1" | tr '[a-z]' '[A-Z]') { opt=$(echo "$1" | tr '[a-z]' '[A-Z]')
for OPT in $OPTS; do [ "$opt" = "$OPT" ] && return; done for OPT in $OPTS; do [ "$opt" = "$OPT" ] && return; done
print_help; exit 1 echo "Unknown option $2"; exit 1
} }
parse_input() # Parse stuff :V parse_input() # Parse stuff :V
@ -62,21 +62,21 @@ parse_input() # Parse stuff :V
--global-config-dir=*) GLOBAL_CONFIG_DIR=${1##--global-config-dir=};; --global-config-dir=*) GLOBAL_CONFIG_DIR=${1##--global-config-dir=};;
--host=*) CROSS_COMPILE=${1##--host=}-;; --host=*) CROSS_COMPILE=${1##--host=}-;;
--enable-*) --enable-*)
opt_exists "${1##--enable-}" opt_exists "${1##--enable-}" "$1"
eval "HAVE_$opt=yes" eval "HAVE_$opt=yes"
;; ;;
--disable-*) --disable-*)
opt_exists "${1##--disable-}" opt_exists "${1##--disable-}" "$1"
eval "HAVE_$opt=no" eval "HAVE_$opt=no"
;; ;;
--with-*) --with-*)
arg="${1##--with-}" arg="${1##--with-}"
val="${arg##*=}" val="${arg##*=}"
opt_exists "${arg%%=*}" opt_exists "${arg%%=*}" "$1"
eval "$opt=\"$val\"" eval "$opt=\"$val\""
;; ;;
-h|--help) print_help; exit 0;; -h|--help) print_help; exit 0;;
*) print_help; exit 1;; *) echo "Unknown option $1"; exit 1;;
esac esac
shift shift
done done