From 3dc8098074be5c04b0e5a57343263bd5ea68bcc9 Mon Sep 17 00:00:00 2001 From: Matthias Krack Date: Fri, 16 Dec 2022 15:39:07 +0100 Subject: [PATCH] Revise processing of -j flag - Accept only integer numbers for -j flag - Allow for -j as standalone flag --- tools/toolchain/install_cp2k_toolchain.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/toolchain/install_cp2k_toolchain.sh b/tools/toolchain/install_cp2k_toolchain.sh index 63571f620f..ab835b6d19 100755 --- a/tools/toolchain/install_cp2k_toolchain.sh +++ b/tools/toolchain/install_cp2k_toolchain.sh @@ -374,7 +374,19 @@ while [ $# -ge 1 ]; do case ${1} in -j) shift - export NPROCS_OVERWRITE="${1}" + case "${1}" in + -*) + export NPROCS_OVERWRITE="$(get_nprocs)" + ;; + [0-9]*) + export NPROCS_OVERWRITE="${1}" + ;; + *) + report_error ${LINENO} \ + "The -j flag can only be followed by an integer number, found ${1}." + exit 1 + ;; + esac ;; -j[0-9]*) export NPROCS_OVERWRITE="${1#-j}"