From 6ceb76e8fb538d0cfa5e7bad02ef35af99d428f6 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 12 Aug 2021 18:12:13 +0200 Subject: [PATCH 1/3] bash_completion: sub-commands dependencies and sync removed --- Pmodules/bash_completion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pmodules/bash_completion b/Pmodules/bash_completion index 76c789a..ed47153 100644 --- a/Pmodules/bash_completion +++ b/Pmodules/bash_completion @@ -39,9 +39,9 @@ _module() { COMPREPLY=() - cmds="add apropos avail clear dependencies display help\ + cmds="add apropos avail clear display help\ initadd initclear initlist initprepend initrm initswitch\ - keyword list load purge refresh rm search show swap switch sync\ + keyword list load purge refresh rm search show swap switch \ unload unuse update use whatis" opts="-c -f -h -i -l -s -t -u -v -H -V\ From 02d1939c81eb7c4f9236f451b6059569b52d53da Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 12 Aug 2021 18:14:37 +0200 Subject: [PATCH 2/3] modulecmd: module sub-command --help bugs fixed --- Pmodules/modulecmd.bash.in | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index dde1dd8..f620f21 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -262,6 +262,7 @@ subcommand_generic0() { args+=( "$1" ) ;; esac + shift 1 done if (( ${#args[@]} > 0 )); then std::die 3 "%s %s: %s\n" \ @@ -459,7 +460,7 @@ subcommand_load() { while (($# > 0)); do case $1 in -H | --help ) - print_help "${subcommand_load}" + print_help "${subcommand}" ;; -f | --force ) opts+=(' -f') @@ -2294,6 +2295,24 @@ if [[ -z "${Subcommands[${subcommand}]}" ]]; then std::die 1 "${CMD}: unknown sub-command -- ${subcommand}\n" fi +case ${subcommand} in + add ) + subcommand='load' + ;; + display ) + subcommand='show' + ;; + keyword ) + subcommand='apropos' + ;; + rm ) + subcommand='unload' + ;; + switch ) + subcommand='swap' + ;; +esac + if [[ -n ${PMODULES_ENV} ]]; then eval "$("${base64}" -d <<< "${PMODULES_ENV}" 2>/dev/null)" if [[ -z ${Version} ]] || [[ ${Version} != ${PMODULES_VERSION} ]]; then @@ -2335,7 +2354,7 @@ if (( ${#GroupDepths[@]} == 0 )); then fi case ${subcommand} in - load|purge|search|switch ) + load|purge|search|swap ) declare -r tmpfile=$( ${mktemp} /tmp/Pmodules.XXXXXX ) \ || std::die 1 "Oops: unable to create tmp file!" ;; From e3d8ee97809fcdfc66dd461b7add91e9411442ff Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 12 Aug 2021 18:27:01 +0200 Subject: [PATCH 3/3] modulecmd: bugfix in removing tmp file in _exit --- Pmodules/modulecmd.bash.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index f620f21..fc51ad6 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -143,7 +143,9 @@ save_env() { _exit() { save_env "${g_env_must_be_saved}" - ${rm} -f "${tmpfile}" + if [[ -n "${tmpfile}" ]] && [[ -e "${tmpfile}" ]]; then + ${rm} -f "${tmpfile}" || : + fi } trap '_exit' EXIT