From ccb02fdf27c8b828f62881460dda99e054b70c1d Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 3 Sep 2020 16:21:39 +0200 Subject: [PATCH] modulecmd.bash.in: implement use-flags with arrays --- Pmodules/modulecmd.bash.in | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 5319f01..311b269 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -463,15 +463,21 @@ subcommand_load() { fi fi local found='' - for flag in "${UseFlags[@]/#/_}" ""; do - # :FIXME: this doesn't work if ${m} is a - # modulename without version - if is_available "${m}${flag}"; then - m+="${flag}" + for flag in "${!UseFlags[@]}"; do + # :FIXME: this doesn't work if ${m} is a + # modulename without version + if is_available "${m}_${flag}"; then + m+="_${flag}" found=':' break fi done + if [[ ! "${found}" ]]; then + # no use-flags set + if is_available "${m}"; then + found=':' + fi + fi if [[ ! "${found}" ]]; then std::info "%s %s: module unavailable -- %s\n" \ "${CMD}" 'load' "${m}"