diff --git a/neko/update/native.sh b/neko/update/native.sh index ef7d9645..d59bce16 100755 --- a/neko/update/native.sh +++ b/neko/update/native.sh @@ -4,7 +4,7 @@ set -eu . neko/update/utils # Confirm that the server is stopped -if [ "$#" != '1' ] || [ "$1" != '--skip-all-confirmations' ]; then +if ! contains '--skip-all-confirmations' "$@"; then say 'Did you stop your server?' printf '[Y/n] > ' read -r yn diff --git a/neko/update/utils b/neko/update/utils index 97fa784f..ec0af597 100644 --- a/neko/update/utils +++ b/neko/update/utils @@ -27,6 +27,19 @@ br() { printf '\n' } +contains() { + target="$1" + shift + + for item in "$@"; do + if [ "${item}" = "${target}" ]; then + return 0 # found + fi + done + + return 1 # not found +} + version() { UPSTREAM_VERSION=$(pnpm pkg get version | sed -e 's/"//g') COMMIT_DATE=$(git show --no-patch --pretty='%cs' FETCH_HEAD | sed -e 's/-//g' | cut -c 3-) diff --git a/update.sh b/update.sh index 8fa81570..3cd623b4 100755 --- a/update.sh +++ b/update.sh @@ -43,7 +43,9 @@ for message in $(find neko/messages -type f ! -name '*.resolved' -print | sort); file=$(basename -- "${message}") if [ ! -f "neko/flags/${file}" ]; then - if [ "$#" != '1' ] || [ "$1" != '--skip-all-confirmations' ]; then + if contains '--skip-all-confirmations' "$@"; then + touch "neko/flags/${file}" + else say 'There is an important notice!' cat "${message}" @@ -63,8 +65,6 @@ for message in $(find neko/messages -type f ! -name '*.resolved' -print | sort); exit 1 ;; esac - else - touch "neko/flags/${file}" fi fi done