From 4b928f779dedb92aba1c5cb5e8343a8c748be5b8 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 21 Mar 2024 10:00:49 +0100 Subject: [PATCH] modbuild: fix in parsing arguments (issue #238) --- Pmodules/modbuild.in | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index c129272..0c31af8 100755 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -202,13 +202,7 @@ parse_args() { # modbuild [options] # the build-script MUST be passed as first argument. # - BUILD_SCRIPT=$(std::get_abspath "$1") - test -r ${BUILD_SCRIPT} || \ - std::die 1 "%s " \ - "Build script does not exist" \ - "or is not readable -- '$_'" - BUILDBLOCK_DIR=$(dirname "${BUILD_SCRIPT}") - shift 1 + (( $# == 0 )) && usage while (( $# > 0 )); do case $1 in @@ -345,17 +339,26 @@ parse_args() { ;; * ) local -- arg="$1" - if [[ "${arg}" == */* ]]; then + local -- tmpvar=$(std::get_abspath "${arg}") + if [[ -r ${tmpvar} ]]; then + BUILD_SCRIPT="${tmpvar}" + BUILDBLOCK_DIR=$(dirname "${BUILD_SCRIPT}") + elif [[ "${arg}" == */* ]]; then module_name="${arg%/*}" versions+=( {arg#*/} ) else versions+=( "$1" ) fi + ;; esac shift done + [[ -z "${BUILD_SCRIPT}" ]] && \ + std::die 1 "%s " \ + "Build script argument missing?" + # if no version is specified on the cmd-line, build all versions (( ${#versions[@]} > 0)) || versions+=( '.*' )