From cdd8d335870481a3a994ab4673dc44e97a78e761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 20 Mar 2023 01:41:15 +0100 Subject: [PATCH] ci: Use built-in option parsing in meson-install This is less concise than the current ad-hoc parsing, but gets us error handling ("unknown option --foo") and is easier to extend. Part-of: --- .gitlab-ci/install-meson-project.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci/install-meson-project.sh b/.gitlab-ci/install-meson-project.sh index fbb62b9d0..c49d50c7f 100755 --- a/.gitlab-ci/install-meson-project.sh +++ b/.gitlab-ci/install-meson-project.sh @@ -14,11 +14,28 @@ usage() { EOF } +TEMP=$(getopt \ + --name=$(basename $0) \ + --options=D \ + -- "$@") + +eval set -- "$TEMP" +unset TEMP + MESON_OPTIONS=() -while [[ $1 =~ ^-D ]]; do - MESON_OPTIONS+=( "$1" ) - shift +while true; do + case "$1" in + -D) + MESON_OPTIONS+=( -D$2 ) + shift 2 + ;; + + --) + shift + break + ;; + esac done if [[ $# -lt 4 ]]; then