fix postional args and support --arg=value

This commit is contained in:
Iliyan Ivanov 2020-07-30 01:53:38 +03:00
parent f4488c930e
commit d41725d9ae
Signed by: iliyan
GPG Key ID: A20B95830B5794F3

View File

@ -29,7 +29,13 @@ create_repo() {
: ${GITEA_SERVER_PUSH_URL:=}
ARGS=()
pos_arg_flag=0
while [[ $# -gt 0 ]]; do
if [ "${pos_arg_flag}" -eq "1" ]; then
ARGS+=("$1")
shift 1
continue
fi
case "$1" in
--url | -u)
GITEA_SERVER_URL="$2"
@ -52,12 +58,11 @@ while [[ $# -gt 0 ]]; do
shift 2
;;
--)
pos_arg_flag=1
shift 1
break
;;
-*)
echo "unknown argument: $1" 1>&2
exit 1
--*=*)
set -- "$(cat - <<<"$1" | cut -d '=' -f1)" "$(cat - <<<"$1" | cut -d '=' -f2-)" "${@:3}"
;;
*)
ARGS+=("$1")