From c8f2920296ac965617436bb407b4e7a7f4dbff20 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Wed, 15 Feb 2017 06:27:58 +1000 Subject: [PATCH] Improve netinstall argument handling --- netinstall.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/netinstall.sh b/netinstall.sh index 7ddab9b..c9bf23d 100644 --- a/netinstall.sh +++ b/netinstall.sh @@ -7,28 +7,31 @@ arkstGithubRepo="FezVrasta/ark-server-tools" steamcmd_user="$1" -channel=${2:-master} # if defined by 2nd argument install the defined version, otherwise install master -shift shift +args=() output=/dev/null - -if [ "$1" = "--verbose" ]; then - output=/dev/fd/1 - shift -elif [[ "$1" =~ ^--output= ]]; then - output="${1#--output=}" - shift -fi - unstable= -if [ "$1" = "--unstable" ]; then - unstable=1 -fi - userinstall= -if [ "$1" = "--perform-user-install" ]; then - userinstall=yes + +for arg in "$@"; do + case "$arg" in + --verbose) output=/dev/fd/1; ;; + --output=*) output="${1#--output=}"; ;; + --unstable) unstable=1; ;; + --perform-user-install) userinstall=yes; ;; + *) + if [ -n "$channel" ]; then + args+="$arg" + else + channel="$arg" + fi + ;; + esac +done + +if [ -z "$channel" ]; then + channel="master" fi if [[ "$steamcmd_user" == "--me" && -z "$userinstall" ]]; then