From 81797d65bad2b1c8fa48357914162b4ecb3002fc Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 29 Oct 2025 12:51:06 +0100 Subject: [PATCH 01/25] follow Lmod rules for path updates Signed-off-by: Achim Gsell --- configure | 6 +++++- init/Makefile | 3 ++- tcl/envmngt.tcl.in | 42 +++++++++++++++++++++++++++++------------- tcl/init.tcl.in | 1 + tcl/subcmd.tcl.in | 18 ++++++++++++++---- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/configure b/configure index 005eded75..1862162a9 100755 --- a/configure +++ b/configure @@ -34,7 +34,7 @@ multilibsupport libdir64 libdir32 versioning silentshdbgsupport \ setshellstartup quarantinesupport autohandling availindepth implicitdefault \ extendeddefault moduleshome initconfin pager pageropts verbosity color \ darkbgcolors lightbgcolors termbg lockedconfigs icase unloadmatchorder \ -searchmatch modulepath loadedmodules quarantinevars wa277 advversspec ml \ +searchmatch modulepath loadedmodules quarantinevars wa277 lmodpath advversspec ml \ windowssupport nearlyforbiddendays implicitrequirement tagabbrev \ tagcolorname mcookieversioncheck availoutput availterseoutput listoutput \ listterseoutput editor variantshortcut bashcompletiondir fishcompletiondir \ @@ -79,6 +79,7 @@ extendeddefault=y advversspec=y ml=y wa277=n +lmodpath=n loadedmodules= quarantinevars= binsearchpath=/usr/bin:/bin:/usr/local/bin @@ -931,6 +932,9 @@ for arg in "$@"; do pythonbin=$(get_package_value "$arg") ;; --with-module-path=*) echo_warning "Option \`--with-module-path' ignored, use \`--modulepath' instead" ;; + --enable-lmod-path|--disable-lmod-path) + # shellcheck disable=SC2034 + lmodpath=$(get_feature_value "$arg") ;; -h|--help) echo_usage exit 0 diff --git a/init/Makefile b/init/Makefile index 19c51a258..afe5c8674 100644 --- a/init/Makefile +++ b/init/Makefile @@ -136,7 +136,7 @@ comp_lint_opts := -a -i --all --icase comp_modtosh_opts := --auto --no-auto --force -f --icase -i comp_path_opts := -d --delim --duplicates comp_rm_path_opts := -d --delim --index -comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 +comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 lmod_path_rule define translate-in-script $(ECHO_GEN) @@ -167,6 +167,7 @@ sed -e 's|@prefix@|$(prefix)|g' \ -e 's|@comp_path_opts@|$(comp_path_opts)|g' \ -e 's|@comp_rm_path_opts@|$(comp_rm_path_opts)|g' \ -e 's|@comp_config_opts@|$(comp_config_opts)|g' \ + -e 's|@comp_lmod_path_rule@|$(comp_lmod_path_rule)|g' \ -e '$(setzshfpathre)' \ -e $$'s|@modulerc@|$(modulerc)|g' \ -e 's|@modulepath@|$(modulepath)|g' \ diff --git a/tcl/envmngt.tcl.in b/tcl/envmngt.tcl.in index 30b8b5eb3..8371975e7 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1807,17 +1807,32 @@ proc add-path {cmd mode dflbhv args} { set val [get-env $var] - foreach dir $path_list { - if {![info exists countarr($dir)] || $allow_dup} { - # ignore env var set empty if no empty entry found in reference - # counter array (sometimes var is cleared by setting it empty not - # unsetting it) - if {$val ne {} || [info exists countarr()]} { - set sep [expr {$val eq $separator ? {} : $separator}] - set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ - "$val$sep$dir"}] + if {[getConf lmod_path_rule]} { + set mpath_list [split $val $separator] + foreach dir $path_list { + if {$bhv eq {prepend}} { + set mpath_list "$dir [lsearch -inline -all -not -exact\ + $mpath_list $dir]" } else { - set val $dir + set mpath_list "[lsearch -inline -all -not -exact\ + $mpath_list $dir] $dir" + } + set val [join $mpath_list $separator] + } + set countarr($dir) 1 + } else { + foreach dir $path_list { + if {![info exists countarr($dir)] || $allow_dup} { + # ignore env var set empty if no empty entry found in reference + # counter array (sometimes var is cleared by setting it empty not + # unsetting it) + if {$val ne {} || [info exists countarr()]} { + set sep [expr {$val eq $separator ? {} : $separator}] + set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ + "$val$sep$dir"}] + } else { + set val $dir + } } } if {[info exists countarr($dir)]} { @@ -2046,7 +2061,8 @@ proc getModulesEnvVarGlobList {{loaded_ctx 0}} { return $envvar_glob_list } -# ;;; Local Variables: *** -# ;;; mode:tcl *** -# ;;; End: *** +# Local Variables: +# Mode: tcl-mode +# tcl-indent-level: 3 +# End: # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in index 1e81e6422..75531400d 100644 --- a/tcl/init.tcl.in +++ b/tcl/init.tcl.in @@ -111,6 +111,7 @@ array set g_config_defs [list\ alias indesym sym tag hidden key} {} {} eltlist}\ list_terse_output {MODULES_LIST_TERSE_OUTPUT {@listterseoutput@} 0 l\ {header idx variant alias indesym sym tag hidden key} {} {} eltlist}\ + lmod_path_rule {MODULES_LMOD_PATH_RULE 1 0 b {0 1}}\ locked_configs {{} {@lockedconfigs@} 0 o}\ logged_events {MODULES_LOGGED_EVENTS {@loggedevents@} 1 l {auto_eval\ requested_eval requested_cmd} {} {} eltlist}\ diff --git a/tcl/subcmd.tcl.in b/tcl/subcmd.tcl.in index a5c90c9fb..1f0145e1c 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -1969,7 +1969,16 @@ proc runModuleUse {cmd mode pos args} { $* { lappend pathlist $path } - default { + default { + if {[info exists ::g_modulepathLabel]} { + foreach key [array names ::g_modulepathLabel] { + set v $::g_modulepathLabel($key) + if {[string equal $v $path]} { + set path $key + break + } + } + } if {$pos eq {remove}} { if {$path in $modpathlist} { lappend pathlist $path @@ -3152,7 +3161,8 @@ proc cmdModuleSpider {show_oneperline show_mtime show_filter search_filter\ $search_match $modpath_list {*}$args } -# ;;; Local Variables: *** -# ;;; mode:tcl *** -# ;;; End: *** +# Local Variables: +# mode:tcl +# tcl-indent-level: 3 +# End: # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: From df8c74885ec84db4d86e4bd7a7ea74f4bb05f12a Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 29 Oct 2025 13:38:23 +0100 Subject: [PATCH 02/25] code not belonging to this PR removed Signed-off-by: Achim Gsell --- tcl/subcmd.tcl.in | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tcl/subcmd.tcl.in b/tcl/subcmd.tcl.in index 1f0145e1c..d8f6ec33b 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -1969,16 +1969,7 @@ proc runModuleUse {cmd mode pos args} { $* { lappend pathlist $path } - default { - if {[info exists ::g_modulepathLabel]} { - foreach key [array names ::g_modulepathLabel] { - set v $::g_modulepathLabel($key) - if {[string equal $v $path]} { - set path $key - break - } - } - } + default { if {$pos eq {remove}} { if {$path in $modpathlist} { lappend pathlist $path From 1c2a7b4758454f3191344deb0e1577b0807c3c7e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 29 Oct 2025 13:40:20 +0100 Subject: [PATCH 03/25] untabify Signed-off-by: Achim Gsell --- tcl/subcmd.tcl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcl/subcmd.tcl.in b/tcl/subcmd.tcl.in index d8f6ec33b..f48091567 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -1969,7 +1969,7 @@ proc runModuleUse {cmd mode pos args} { $* { lappend pathlist $path } - default { + default { if {$pos eq {remove}} { if {$path in $modpathlist} { lappend pathlist $path From 3015e138ccb5b30ab86d7894b22dab4146fca6c9 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 16:05:59 +0100 Subject: [PATCH 04/25] config option renamed and add-path reviewed Signed-off-by: Achim Gsell --- init/Makefile | 4 ++-- tcl/envmngt.tcl.in | 52 ++++++++++++++++++++++------------------------ tcl/init.tcl.in | 2 +- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/init/Makefile b/init/Makefile index afe5c8674..ddf2b8b68 100644 --- a/init/Makefile +++ b/init/Makefile @@ -136,7 +136,7 @@ comp_lint_opts := -a -i --all --icase comp_modtosh_opts := --auto --no-auto --force -f --icase -i comp_path_opts := -d --delim --duplicates comp_rm_path_opts := -d --delim --index -comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 lmod_path_rule +comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 path_entry_reorder define translate-in-script $(ECHO_GEN) @@ -167,7 +167,7 @@ sed -e 's|@prefix@|$(prefix)|g' \ -e 's|@comp_path_opts@|$(comp_path_opts)|g' \ -e 's|@comp_rm_path_opts@|$(comp_rm_path_opts)|g' \ -e 's|@comp_config_opts@|$(comp_config_opts)|g' \ - -e 's|@comp_lmod_path_rule@|$(comp_lmod_path_rule)|g' \ + -e 's|@comp_path_entry_reorder@|$(comp_path_entry_reorder)|g' \ -e '$(setzshfpathre)' \ -e $$'s|@modulerc@|$(modulerc)|g' \ -e 's|@modulepath@|$(modulepath)|g' \ diff --git a/tcl/envmngt.tcl.in b/tcl/envmngt.tcl.in index 8371975e7..9c285e6e9 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1788,7 +1788,7 @@ proc add-path {cmd mode dflbhv args} { set bhv $dflbhv } else { lassign [parsePathCommandArgs $cmd $mode $dflbhv {*}$args] separator\ - allow_dup idx_val ign_refcount val_set_is_delim glob_match bhv var\ + allow_dup idx_val ign_refcount val_set_is_delim glob_match bhv var\ path_list } @@ -1807,33 +1807,29 @@ proc add-path {cmd mode dflbhv args} { set val [get-env $var] - if {[getConf lmod_path_rule]} { - set mpath_list [split $val $separator] - foreach dir $path_list { - if {$bhv eq {prepend}} { - set mpath_list "$dir [lsearch -inline -all -not -exact\ - $mpath_list $dir]" - } else { - set mpath_list "[lsearch -inline -all -not -exact\ - $mpath_list $dir] $dir" + foreach dir $path_list { + set dir_removed 0 + if {[getConf path_entry_reorder]} { + if {[info exists countarr($dir)] && ! $allow_dup} { + # remove dir if in $val and duplicates are not allowed + set mpath_list [split $val $separator] + set mpath_list [lsearch -inline -all -not -exact $mpath_list $dir] + set val [join $mpath_list $separator] + set countarr($dir) 0 + set dir_removed 1 } - set val [join $mpath_list $separator] } - set countarr($dir) 1 - } else { - foreach dir $path_list { - if {![info exists countarr($dir)] || $allow_dup} { - # ignore env var set empty if no empty entry found in reference - # counter array (sometimes var is cleared by setting it empty not - # unsetting it) - if {$val ne {} || [info exists countarr()]} { - set sep [expr {$val eq $separator ? {} : $separator}] - set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ - "$val$sep$dir"}] + if {![info exists countarr($dir)] || $dir_removed || $allow_dup} { + # ignore env var set empty if no empty entry found in reference + # counter array (sometimes var is cleared by setting it empty not + # unsetting it) + if {$val ne {} || [info exists countarr()]} { + set sep [expr {$val eq $separator ? {} : $separator}] + set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ + "$val$sep$dir"}] } else { set val $dir } - } } if {[info exists countarr($dir)]} { # do not increase counter if bare separator string is added or if @@ -2061,8 +2057,10 @@ proc getModulesEnvVarGlobList {{loaded_ctx 0}} { return $envvar_glob_list } -# Local Variables: -# Mode: tcl-mode -# tcl-indent-level: 3 -# End: +# ;;; Local Variables: +# ;;; Mode: tcl-mode +# ;;; tcl-indent-level: 3 +# ;;; tcl-continued-indent-level: 3 +# ;;; indent-tabs-mode: nil +# ;;; End: # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in index 75531400d..bf7b9fcd4 100644 --- a/tcl/init.tcl.in +++ b/tcl/init.tcl.in @@ -111,7 +111,7 @@ array set g_config_defs [list\ alias indesym sym tag hidden key} {} {} eltlist}\ list_terse_output {MODULES_LIST_TERSE_OUTPUT {@listterseoutput@} 0 l\ {header idx variant alias indesym sym tag hidden key} {} {} eltlist}\ - lmod_path_rule {MODULES_LMOD_PATH_RULE 1 0 b {0 1}}\ + path_entry_reorder {MODULES_PATH_ENTRY_REORDER 1 0 b {0 1}}\ locked_configs {{} {@lockedconfigs@} 0 o}\ logged_events {MODULES_LOGGED_EVENTS {@loggedevents@} 1 l {auto_eval\ requested_eval requested_cmd} {} {} eltlist}\ From 1cd103b09aaa5b21abd2602c97896e2819e211d6 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 16:55:49 +0100 Subject: [PATCH 05/25] configure fixed Signed-off-by: Achim Gsell --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 1862162a9..6ddfb11f5 100755 --- a/configure +++ b/configure @@ -79,7 +79,7 @@ extendeddefault=y advversspec=y ml=y wa277=n -lmodpath=n +pathentryreorder=n loadedmodules= quarantinevars= binsearchpath=/usr/bin:/bin:/usr/local/bin @@ -932,9 +932,9 @@ for arg in "$@"; do pythonbin=$(get_package_value "$arg") ;; --with-module-path=*) echo_warning "Option \`--with-module-path' ignored, use \`--modulepath' instead" ;; - --enable-lmod-path|--disable-lmod-path) + --enable-path-entry-reorder|--disable-path-entry-reorder) # shellcheck disable=SC2034 - lmodpath=$(get_feature_value "$arg") ;; + pathentryreorder=$(get_feature_value "$arg") ;; -h|--help) echo_usage exit 0 From 45a90b116c34e4c5977e0de9fe3fcca228b9657a Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 17:28:56 +0100 Subject: [PATCH 06/25] comments added to make design more clear Signed-off-by: Achim Gsell --- tcl/envmngt.tcl.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tcl/envmngt.tcl.in b/tcl/envmngt.tcl.in index 9c285e6e9..99173471e 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1808,14 +1808,23 @@ proc add-path {cmd mode dflbhv args} { set val [get-env $var] foreach dir $path_list { + # With the following variable, we indicate that $dir has been removed + # from the path if path_entry_reorder is true and duplicates are not + # allowed. set dir_removed 0 if {[getConf path_entry_reorder]} { if {[info exists countarr($dir)] && ! $allow_dup} { - # remove dir if in $val and duplicates are not allowed + # if $dir is in $val and duplicates are not allowed: + # first remove all occurences of $dir in $val + # and add $dir at the beginning or end later again set mpath_list [split $val $separator] set mpath_list [lsearch -inline -all -not -exact $mpath_list $dir] set val [join $mpath_list $separator] + + # Set counter to 0. Unfortunatelly we cannot use countarr($dir) + # in the following if statement. set countarr($dir) 0 + # make sure $dir is added again set dir_removed 1 } } From 997f58b3cfd41858aff82a9bfd2a51e3e981d08f Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 17:38:53 +0100 Subject: [PATCH 07/25] Emacs local variables fixed Signed-off-by: Achim Gsell --- tcl/subcmd.tcl.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tcl/subcmd.tcl.in b/tcl/subcmd.tcl.in index f48091567..4b2b18ca4 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -3152,8 +3152,10 @@ proc cmdModuleSpider {show_oneperline show_mtime show_filter search_filter\ $search_match $modpath_list {*}$args } -# Local Variables: -# mode:tcl -# tcl-indent-level: 3 -# End: +# ;;; Local Variables: +# ;;; Mode: tcl-mode +# ;;; tcl-indent-level: 3 +# ;;; tcl-continued-indent-level: 3 +# ;;; indent-tabs-mode: nil +# ;;; End: # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: From 967b8c08be2db2bd88c188632582be54d0a85ecf Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 10 Nov 2025 13:28:56 +0100 Subject: [PATCH 08/25] substitution for pathentryreorder added to Makefile Signed-off-by: Achim Gsell --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 93af6cbec..90c363a46 100644 --- a/Makefile +++ b/Makefile @@ -443,6 +443,7 @@ sed -e 's|@prefix@|$(prefix)|g' \ -e 's|@sourcecache@|$(setsourcecache)|g' \ -e 's|@searchmatch@|$(searchmatch)|g' \ -e 's|@wa277@|$(setwa277)|g' \ + -e 's|@pathentryreorder@|$(pathentryreorder)|g' \ -e 's|@icase@|$(icase)|g' \ -e 's|@nearlyforbiddendays@|$(nearlyforbiddendays)|g' \ -e 's|@tagabbrev@|$(tagabbrev)|g' \ From 8866671db2d581e91582742e94f422a258149174 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 10 Nov 2025 13:30:41 +0100 Subject: [PATCH 09/25] Option --enable-path-entry-reoder fixed Signed-off-by: Achim Gsell --- configure | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 6ddfb11f5..a0c225ede 100755 --- a/configure +++ b/configure @@ -34,7 +34,7 @@ multilibsupport libdir64 libdir32 versioning silentshdbgsupport \ setshellstartup quarantinesupport autohandling availindepth implicitdefault \ extendeddefault moduleshome initconfin pager pageropts verbosity color \ darkbgcolors lightbgcolors termbg lockedconfigs icase unloadmatchorder \ -searchmatch modulepath loadedmodules quarantinevars wa277 lmodpath advversspec ml \ +searchmatch modulepath loadedmodules quarantinevars wa277 pathentryreorder advversspec ml \ windowssupport nearlyforbiddendays implicitrequirement tagabbrev \ tagcolorname mcookieversioncheck availoutput availterseoutput listoutput \ listterseoutput editor variantshortcut bashcompletiondir fishcompletiondir \ @@ -804,6 +804,9 @@ for arg in "$@"; do --enable-mcookie-version-check*|--disable-mcookie-version-check) # shellcheck disable=SC2034 mcookieversioncheck=$(get_feature_value "$arg") ;; + --enable-path-entry-reorder*|--disable-path-entry-reorder) + # shellcheck disable=SC2034 + pathentryreorder=$(get_feature_value "$arg") ;; --with-bin-search-path=*|--without-bin-search-path) binsearchpath=$(get_package_value "$arg") ;; --with-moduleshome=*|--without-moduleshome) @@ -932,9 +935,6 @@ for arg in "$@"; do pythonbin=$(get_package_value "$arg") ;; --with-module-path=*) echo_warning "Option \`--with-module-path' ignored, use \`--modulepath' instead" ;; - --enable-path-entry-reorder|--disable-path-entry-reorder) - # shellcheck disable=SC2034 - pathentryreorder=$(get_feature_value "$arg") ;; -h|--help) echo_usage exit 0 From 8e0119d8855ad5e4342305d44cc126a79d5b628e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 10 Nov 2025 13:32:35 +0100 Subject: [PATCH 10/25] Use @pathentryreorder@ to set default Signed-off-by: Achim Gsell --- tcl/init.tcl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in index bf7b9fcd4..d61422f8e 100644 --- a/tcl/init.tcl.in +++ b/tcl/init.tcl.in @@ -111,7 +111,7 @@ array set g_config_defs [list\ alias indesym sym tag hidden key} {} {} eltlist}\ list_terse_output {MODULES_LIST_TERSE_OUTPUT {@listterseoutput@} 0 l\ {header idx variant alias indesym sym tag hidden key} {} {} eltlist}\ - path_entry_reorder {MODULES_PATH_ENTRY_REORDER 1 0 b {0 1}}\ + path_entry_reorder {MODULES_PATH_ENTRY_REORDER @pathentryreorder@ 0 b {0 1}}\ locked_configs {{} {@lockedconfigs@} 0 o}\ logged_events {MODULES_LOGGED_EVENTS {@loggedevents@} 1 l {auto_eval\ requested_eval requested_cmd} {} {} eltlist}\ From d0cb4e1f3d30bf7ddc3a7e5c6e52d1a26bcf7e18 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 12 Nov 2025 14:27:51 +0100 Subject: [PATCH 11/25] configuration option property fixed for path_entry_reorder Signed-off-by: Achim Gsell --- tcl/init.tcl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in index d61422f8e..643d1c823 100644 --- a/tcl/init.tcl.in +++ b/tcl/init.tcl.in @@ -111,7 +111,7 @@ array set g_config_defs [list\ alias indesym sym tag hidden key} {} {} eltlist}\ list_terse_output {MODULES_LIST_TERSE_OUTPUT {@listterseoutput@} 0 l\ {header idx variant alias indesym sym tag hidden key} {} {} eltlist}\ - path_entry_reorder {MODULES_PATH_ENTRY_REORDER @pathentryreorder@ 0 b {0 1}}\ + path_entry_reorder {MODULES_PATH_ENTRY_REORDER @pathentryreorder@ 0 0 b {0 1}}\ locked_configs {{} {@lockedconfigs@} 0 o}\ logged_events {MODULES_LOGGED_EVENTS {@loggedevents@} 1 l {auto_eval\ requested_eval requested_cmd} {} {} eltlist}\ From c040243fc128f54368c5da78c0ce6d11b3c67b55 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 12 Nov 2025 15:12:41 +0100 Subject: [PATCH 12/25] revised code if path_entry_reoder is set Signed-off-by: Achim Gsell --- tcl/envmngt.tcl.in | 67 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/tcl/envmngt.tcl.in b/tcl/envmngt.tcl.in index 99173471e..895534657 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1808,47 +1808,46 @@ proc add-path {cmd mode dflbhv args} { set val [get-env $var] foreach dir $path_list { - # With the following variable, we indicate that $dir has been removed - # from the path if path_entry_reorder is true and duplicates are not - # allowed. - set dir_removed 0 - if {[getConf path_entry_reorder]} { - if {[info exists countarr($dir)] && ! $allow_dup} { - # if $dir is in $val and duplicates are not allowed: - # first remove all occurences of $dir in $val - # and add $dir at the beginning or end later again - set mpath_list [split $val $separator] - set mpath_list [lsearch -inline -all -not -exact $mpath_list $dir] - set val [join $mpath_list $separator] - - # Set counter to 0. Unfortunatelly we cannot use countarr($dir) - # in the following if statement. - set countarr($dir) 0 - # make sure $dir is added again - set dir_removed 1 - } - } - if {![info exists countarr($dir)] || $dir_removed || $allow_dup} { - # ignore env var set empty if no empty entry found in reference - # counter array (sometimes var is cleared by setting it empty not - # unsetting it) - if {$val ne {} || [info exists countarr()]} { + if {[getConf path_entry_reorder] && [info exists countarr($dir)]\ + && ! $allow_dup} { + # if $dir is in $val and duplicates are not allowed: + # first remove all occurences of $dir in $val + # and add $dir at the beginning or end if $val + # is not the empty string + set mpath_list [split $val $separator] + set mpath_list [lsearch -inline -all -not -exact $mpath_list $dir] + set val [join $mpath_list $separator] + if {$val ne {}} { set sep [expr {$val eq $separator ? {} : $separator}] set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ "$val$sep$dir"}] + } else { + set val $dir + } + set countarr($dir) 1 + } else { + if {![info exists countarr($dir)] || $allow_dup} { + # ignore env var set empty if no empty entry found in reference + # counter array (sometimes var is cleared by setting it empty not + # unsetting it) + if {$val ne {} || [info exists countarr()]} { + set sep [expr {$val eq $separator ? {} : $separator}] + set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ + "$val$sep$dir"}] } else { set val $dir } - } - if {[info exists countarr($dir)]} { - # do not increase counter if bare separator string is added or if - # reference count is ignored (--ignore-refcount set) unless if - # duplicate mode is enabled (--duplicates set) - if {!$val_set_is_delim && (!$ign_refcount || $allow_dup)} { - incr countarr($dir) } - } else { - set countarr($dir) 1 + if {[info exists countarr($dir)]} { + # do not increase counter if bare separator string is added or if + # reference count is ignored (--ignore-refcount set) unless if + # duplicate mode is enabled (--duplicates set) + if {!$val_set_is_delim && (!$ign_refcount || $allow_dup)} { + incr countarr($dir) + } + } else { + set countarr($dir) 1 + } } } From d0c92080028127dc87e2c53b2c42e92ee672505c Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 12 Nov 2025 15:31:09 +0100 Subject: [PATCH 13/25] untabify Signed-off-by: Achim Gsell --- tcl/envmngt.tcl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcl/envmngt.tcl.in b/tcl/envmngt.tcl.in index 895534657..ffc347348 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1788,7 +1788,7 @@ proc add-path {cmd mode dflbhv args} { set bhv $dflbhv } else { lassign [parsePathCommandArgs $cmd $mode $dflbhv {*}$args] separator\ - allow_dup idx_val ign_refcount val_set_is_delim glob_match bhv var\ + allow_dup idx_val ign_refcount val_set_is_delim glob_match bhv var\ path_list } From 4e057766e32791a9bd8f2af31d7af7807a26b35b Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 20 Nov 2025 14:02:19 +0100 Subject: [PATCH 14/25] path_entry_reorder code reviewed Signed-off-by: Achim Gsell --- tcl/envmngt.tcl.in | 57 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/tcl/envmngt.tcl.in b/tcl/envmngt.tcl.in index ffc347348..463d228a3 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1808,46 +1808,45 @@ proc add-path {cmd mode dflbhv args} { set val [get-env $var] foreach dir $path_list { + # if path_entry_reorder is TRUE && dir is in path + # && duplicates are NOT allowed: + # path: remove all occurences of $dir + # if path_entry_reorder is TRUE || dir is NOT in path + # || duplicates are allowed: + # path: append/prepend $dir if {[getConf path_entry_reorder] && [info exists countarr($dir)]\ && ! $allow_dup} { - # if $dir is in $val and duplicates are not allowed: - # first remove all occurences of $dir in $val - # and add $dir at the beginning or end if $val - # is not the empty string set mpath_list [split $val $separator] set mpath_list [lsearch -inline -all -not -exact $mpath_list $dir] set val [join $mpath_list $separator] - if {$val ne {}} { + } + if {[getConf path_entry_reorder] || ![info exists countarr($dir)]\ + || $allow_dup} { + # ignore env var set empty if no empty entry found in reference + # counter array (sometimes var is cleared by setting it empty not + # unsetting it) + if {$val ne {} || [info exists countarr()]} { set sep [expr {$val eq $separator ? {} : $separator}] set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ - "$val$sep$dir"}] + "$val$sep$dir"}] } else { set val $dir } - set countarr($dir) 1 - } else { - if {![info exists countarr($dir)] || $allow_dup} { - # ignore env var set empty if no empty entry found in reference - # counter array (sometimes var is cleared by setting it empty not - # unsetting it) - if {$val ne {} || [info exists countarr()]} { - set sep [expr {$val eq $separator ? {} : $separator}] - set val [expr {$bhv eq {prepend} ? "$dir$sep$val" :\ - "$val$sep$dir"}] - } else { - set val $dir - } - } - if {[info exists countarr($dir)]} { - # do not increase counter if bare separator string is added or if - # reference count is ignored (--ignore-refcount set) unless if - # duplicate mode is enabled (--duplicates set) - if {!$val_set_is_delim && (!$ign_refcount || $allow_dup)} { - incr countarr($dir) - } - } else { - set countarr($dir) 1 + } + #### ref-counting + # if $dir is NOT in path + # set ref-count 1 + # else if duplicates are allowed || ref-counting is NOT ignored + # incr ref-count + if {[info exists countarr($dir)]} { + # do not increase counter if bare separator string is added or if + # reference count is ignored (--ignore-refcount set) unless if + # duplicate mode is enabled (--duplicates set) + if {!$val_set_is_delim && (!$ign_refcount || $allow_dup)} { + incr countarr($dir) } + } else { + set countarr($dir) 1 } } From 79309f2c7f6c32b40113508ff2ae2d303b9b8dd2 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 2 Dec 2025 15:00:30 +0100 Subject: [PATCH 15/25] add-path reviewed Signed-off-by: Achim Gsell --- tcl/envmngt.tcl.in | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tcl/envmngt.tcl.in b/tcl/envmngt.tcl.in index 463d228a3..e338b2f47 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1808,18 +1808,19 @@ proc add-path {cmd mode dflbhv args} { set val [get-env $var] foreach dir $path_list { - # if path_entry_reorder is TRUE && dir is in path - # && duplicates are NOT allowed: - # path: remove all occurences of $dir - # if path_entry_reorder is TRUE || dir is NOT in path - # || duplicates are allowed: - # path: append/prepend $dir + # remove $dir from path only if path_entry_reorder is true and + # $dir is already in path and duplicates are NOT allowed. if {[getConf path_entry_reorder] && [info exists countarr($dir)]\ && ! $allow_dup} { set mpath_list [split $val $separator] set mpath_list [lsearch -inline -all -not -exact $mpath_list $dir] set val [join $mpath_list $separator] } + # add $dir to beginning or end only if path_entry_reorder is true or + # $dir is NOT in path or duplicates are allowed. + # Please note: if path_entry_reorder is true and duplicates are not + # allowed, $dir is not in path ($val) - either it was not in or it + # had been removed. Hence we have to add it. if {[getConf path_entry_reorder] || ![info exists countarr($dir)]\ || $allow_dup} { # ignore env var set empty if no empty entry found in reference @@ -1836,17 +1837,14 @@ proc add-path {cmd mode dflbhv args} { #### ref-counting # if $dir is NOT in path # set ref-count 1 - # else if duplicates are allowed || ref-counting is NOT ignored - # incr ref-count - if {[info exists countarr($dir)]} { - # do not increase counter if bare separator string is added or if - # reference count is ignored (--ignore-refcount set) unless if - # duplicate mode is enabled (--duplicates set) - if {!$val_set_is_delim && (!$ign_refcount || $allow_dup)} { - incr countarr($dir) - } - } else { + # else + # do NOT increase counter if bare separator string is added or if + # reference count is ignored (--ignore-refcount set) unless if + # duplicate mode is enabled (--duplicates set) + if {![info exists countarr($dir)]} { set countarr($dir) 1 + } elseif {!$val_set_is_delim && (!$ign_refcount || $allow_dup)} { + incr countarr($dir) } } From b9b7009022c6a8ca2855129dc9c855c1f946623f Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 8 Dec 2025 18:21:09 +0100 Subject: [PATCH 16/25] documentation of path_entry_reorder added (still draft) Signed-off-by: Achim Gsell --- doc/source/module.rst | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/doc/source/module.rst b/doc/source/module.rst index 70501b680..bacd8de21 100644 --- a/doc/source/module.rst +++ b/doc/source/module.rst @@ -1370,6 +1370,30 @@ Module Sub-Commands sub-command when changing this configuration option from its default value. See :envvar:`MODULES_PAGER` description for details. + .. mconfig:: path_entry_reorder + + Change order of entry in a path-like environment variable, when + :mfcmd:`prepend-path`, :mfcmd:`append-path` or :subcmd:`use` target + a path entry that is already defined in the environment variable. + + The default behavior of :mfcmd:`prepend-path`, :mfcmd:`append-path` and + :subcmd:`use` is not to update the value if a path-like environment + variable, if they target a path entry that is already defined in the + environment variable. If this config option is set to 1, an existing + path entry is moved to the beginning respective end unless duplicates + are allowed. This is the default behavior of Lmod. + + Default value is 0. It can be changed at installation time with + :instopt:`--with-path-entry-reorder` option. The + :envvar:`MODULES_PATH_ENTRY_REORDER` environment variable is defined by + :subcmd:`config` sub-command when changing this configuration option from + its default value. See :envvar:`MODULES_PATH_ENTRY_REORDER` description + for details. + + .. only:: html + + .. versionadded:: 5.x + .. mconfig:: protected_envvars Prevents any modification of listed environment variables (colon `:` @@ -5274,6 +5298,19 @@ ENVIRONMENT .. versionchanged:: 5.5 No pager when :file:`modulecmd.tcl` is run for scripting languages +.. envvar:: MODULES_PATH_ENTRY_REORDER + + The default behavior of :mfcmd:`prepend-path`, :mfcmd:`append-path` and + :subcmd:`use` is not to update the value if a path-like environment + variable, if they target a path entry that is already defined in the + environment variable. If this config option is set to 1, an existing + path entry is moved to the beginning respective end unless duplicates + are allowed. This is the default behavior of Lmod. + + .. only:: html + + .. versionadded:: 5.x + .. envvar:: MODULES_PROTECTED_ENVVARS A colon separated list of environment variable names that should not be From 94081317dfcbf7ce3f548ebc5cd3a1bbdedf9713 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 10 Dec 2025 17:03:25 +0100 Subject: [PATCH 17/25] documentation of path_entry_reorder updated Signed-off-by: Achim Gsell --- doc/source/module.rst | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/doc/source/module.rst b/doc/source/module.rst index bacd8de21..20971b141 100644 --- a/doc/source/module.rst +++ b/doc/source/module.rst @@ -1376,14 +1376,7 @@ Module Sub-Commands :mfcmd:`prepend-path`, :mfcmd:`append-path` or :subcmd:`use` target a path entry that is already defined in the environment variable. - The default behavior of :mfcmd:`prepend-path`, :mfcmd:`append-path` and - :subcmd:`use` is not to update the value if a path-like environment - variable, if they target a path entry that is already defined in the - environment variable. If this config option is set to 1, an existing - path entry is moved to the beginning respective end unless duplicates - are allowed. This is the default behavior of Lmod. - - Default value is 0. It can be changed at installation time with + Default value is 0. It can be changed at installation time with the :instopt:`--with-path-entry-reorder` option. The :envvar:`MODULES_PATH_ENTRY_REORDER` environment variable is defined by :subcmd:`config` sub-command when changing this configuration option from @@ -5300,12 +5293,28 @@ ENVIRONMENT .. envvar:: MODULES_PATH_ENTRY_REORDER - The default behavior of :mfcmd:`prepend-path`, :mfcmd:`append-path` and - :subcmd:`use` is not to update the value if a path-like environment - variable, if they target a path entry that is already defined in the - environment variable. If this config option is set to 1, an existing - path entry is moved to the beginning respective end unless duplicates - are allowed. This is the default behavior of Lmod. + This environment variable changes the behavior of :mfcmd:`prepend-path`, :mfcmd:`append-path` and :subcmd:`use`. + + If set to 1, and one of these commands targets a path entry that already exists in the environment variable, the entry is moved to the beginning or end (depending on the command), unless duplicates are allowed. This is the default behavior in Lmod. + If set to 0, the environment variable is not modified when the entry already exists. + + Example: + + .. parsed-literal:: + + :ps:`$` module config path_entry_reorder 0 + :ps:`$` module append-path PATHVAR /foo + :ps:`$` module append-path PATHVAR /bar + :ps:`$` module append-path PATHVAR /foo + :ps:`$` echo $PATHVAR + /foo:/bar + :ps:`$` module config path_entry_reorder 1 + :ps:`$` module append-path PATHVAR /foo + :ps:`$` echo $PATHVAR + /bar:/foo + :ps:`$` module append-path --duplicates PATHVAR /bar + :ps:`$` echo $PATHVAR + /bar:/foo:/bar .. only:: html From 7e163e79d112095a69d8b9b71338100f50583e9a Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 12 Dec 2025 19:21:35 +0100 Subject: [PATCH 18/25] documentation updated Signed-off-by: Achim Gsell --- INSTALL.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INSTALL.rst b/INSTALL.rst index 9322b9d1e..63c3a4972 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -1723,6 +1723,9 @@ installation. | | | :envvar:`MODULES_PAGER`, | | | | | | :option:`--paginate`, :option:`--no-pager` | | | +-----------------------------------+----------------------------------------------+----------------------------------------------+--------------+-----------+ +| :mconfig:`path_entry_reorder` | ``0`` | :instopt:`--enable-path-entry-reorder`, | | | +| | | :envvar:`MODULES_PATH_ENTRY_REORDER` | | | ++-----------------------------------+----------------------------------------------+----------------------------------------------+--------------+-----------+ | :mconfig:`protected_envvars` | *Unset by default* | :envvar:`MODULES_PROTECTED_ENVVARS` | | | +-----------------------------------+----------------------------------------------+----------------------------------------------+--------------+-----------+ | :mconfig:`quarantine_support` | ``0`` | :instopt:`--enable-quarantine-support`, | X | | From 2e65696c0a86da8e3a2652001b86dabff328273a Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 12 Dec 2025 19:23:59 +0100 Subject: [PATCH 19/25] documentation updated Signed-off-by: Achim Gsell --- doc/source/changes.rst | 2 ++ doc/source/module.rst | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 957478acd..40baa77f4 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -1279,6 +1279,8 @@ The following Modules configuration option has been introduced on Modules 5. | 5.6 | :mconfig:`spider_output`, :mconfig:`spider_terse_output`, | | | :mconfig:`spider_indepth`, :mconfig:`require_via` | +------------+-----------------------------------------------------------------+ +| 5.7 | :mconfig:`path_entry_reorder` | ++------------+-----------------------------------------------------------------+ :mconfig:`auto_handling` diff --git a/doc/source/module.rst b/doc/source/module.rst index 20971b141..e63f8041f 100644 --- a/doc/source/module.rst +++ b/doc/source/module.rst @@ -1376,7 +1376,7 @@ Module Sub-Commands :mfcmd:`prepend-path`, :mfcmd:`append-path` or :subcmd:`use` target a path entry that is already defined in the environment variable. - Default value is 0. It can be changed at installation time with the + Default value is ``0``. It can be changed at installation time with the :instopt:`--with-path-entry-reorder` option. The :envvar:`MODULES_PATH_ENTRY_REORDER` environment variable is defined by :subcmd:`config` sub-command when changing this configuration option from @@ -5295,8 +5295,8 @@ ENVIRONMENT This environment variable changes the behavior of :mfcmd:`prepend-path`, :mfcmd:`append-path` and :subcmd:`use`. - If set to 1, and one of these commands targets a path entry that already exists in the environment variable, the entry is moved to the beginning or end (depending on the command), unless duplicates are allowed. This is the default behavior in Lmod. - If set to 0, the environment variable is not modified when the entry already exists. + If set to ``1``, and one of these commands targets a path entry that already exists in the environment variable, the entry is moved to the beginning or end (depending on the command), unless duplicates are allowed. This is the default behavior in Lmod. + If set to ``0``, the environment variable is not modified when the entry already exists. Example: From 87e23ee7876990ad4bc7d8fc896f411e371dc01a Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 12 Dec 2025 19:26:03 +0100 Subject: [PATCH 20/25] testsuite updated Signed-off-by: Achim Gsell --- Makefile.inc.in | 3 +++ init/Makefile | 2 +- init/fish_completion | 2 +- init/zsh-functions/_module.in | 2 +- site.exp.in | 2 ++ tcl/init.tcl.in | 2 +- testsuite/install.00-init/010-environ.exp | 3 +++ testsuite/modules.00-init/010-environ.exp | 3 +++ testsuite/modules.70-maint/220-config.exp | 3 +++ 9 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Makefile.inc.in b/Makefile.inc.in index e9ad51750..aac1ab3ca 100644 --- a/Makefile.inc.in +++ b/Makefile.inc.in @@ -158,6 +158,9 @@ variantshortcut := @variantshortcut@ # editor editor := @editor@ +# Lmod path order +pathentryreorder := @pathentryreorder@ + # shell completion location bashcompletiondir := @bashcompletiondir@ fishcompletiondir := @fishcompletiondir@ diff --git a/init/Makefile b/init/Makefile index ddf2b8b68..3bf487b03 100644 --- a/init/Makefile +++ b/init/Makefile @@ -136,7 +136,7 @@ comp_lint_opts := -a -i --all --icase comp_modtosh_opts := --auto --no-auto --force -f --icase -i comp_path_opts := -d --delim --duplicates comp_rm_path_opts := -d --delim --index -comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 path_entry_reorder +comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 define translate-in-script $(ECHO_GEN) diff --git a/init/fish_completion b/init/fish_completion index 943429bae..1b0a07a5c 100644 --- a/init/fish_completion +++ b/init/fish_completion @@ -87,7 +87,7 @@ complete -c module -n '__fish_module_use_stashlist' -f -a "(module stashlist --c /Stash collection list\$/d; \ /:\$/d; \ /:ERROR:/d;')" -complete -c module -n '__fish_module_use_config' -f -a "--dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277" +complete -c module -n '__fish_module_use_config' -f -a "--dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277" complete -f -n '__fish_module_no_subcommand' -c module -a 'help' --description 'Print this or modulefile(s) help info' complete -f -n '__fish_module_no_subcommand' -c module -a 'avail' --description 'List all or matching available modules' diff --git a/init/zsh-functions/_module.in b/init/zsh-functions/_module.in index 380773e19..397b64afe 100644 --- a/init/zsh-functions/_module.in +++ b/init/zsh-functions/_module.in @@ -378,7 +378,7 @@ _module() { _arguments \ '--dump-state[Report each state value of current Modules execution]' \ '--reset[Unset environment variable relative to configuration key]' \ - '1:configuration key:(abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277)' \ + '1:configuration key:(abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc implicit_default implicit_requirement list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml nearly_forbidden_days pager path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277)' \ && ret=0 ;; (edit) diff --git a/site.exp.in b/site.exp.in index 6d35a6b27..d5fff5e3d 100644 --- a/site.exp.in +++ b/site.exp.in @@ -117,6 +117,8 @@ set install_variantshortcut "@variantshortcut@" set install_editor "@editor@" +set install_pathentryreorder "@pathentryreorder@" + set install_bashcompletiondir "@bashcompletiondir@" set install_fishcompletiondir "@fishcompletiondir@" set install_zshcompletiondir "@zshcompletiondir@" diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in index 643d1c823..bae1e83ce 100644 --- a/tcl/init.tcl.in +++ b/tcl/init.tcl.in @@ -111,7 +111,6 @@ array set g_config_defs [list\ alias indesym sym tag hidden key} {} {} eltlist}\ list_terse_output {MODULES_LIST_TERSE_OUTPUT {@listterseoutput@} 0 l\ {header idx variant alias indesym sym tag hidden key} {} {} eltlist}\ - path_entry_reorder {MODULES_PATH_ENTRY_REORDER @pathentryreorder@ 0 0 b {0 1}}\ locked_configs {{} {@lockedconfigs@} 0 o}\ logged_events {MODULES_LOGGED_EVENTS {@loggedevents@} 1 l {auto_eval\ requested_eval requested_cmd} {} {} eltlist}\ @@ -123,6 +122,7 @@ array set g_config_defs [list\ nearly_forbidden_days {MODULES_NEARLY_FORBIDDEN_DAYS @nearlyforbiddendays@\ 0 i {0 365} {} {} intbe}\ pager {MODULES_PAGER {@pagercmd@} 0 s}\ + path_entry_reorder {MODULES_PATH_ENTRY_REORDER @pathentryreorder@ 0 0 b {0 1}}\ protected_envvars {MODULES_PROTECTED_ENVVARS 0 l}\ rcfile {MODULERCFILE 0 l}\ redirect_output {MODULES_REDIRECT_OUTPUT 1 0 b {0 1}}\ diff --git a/testsuite/install.00-init/010-environ.exp b/testsuite/install.00-init/010-environ.exp index 528786aec..ce76cb5c6 100644 --- a/testsuite/install.00-init/010-environ.exp +++ b/testsuite/install.00-init/010-environ.exp @@ -194,4 +194,7 @@ catch {unset env(MODULERCFILE)} # setup basic locale for tests set env(LANG) "C" +# ensure that tests doesn't run with Lmod path order +unsetenv_var MODULES_PATH_ENTRY_REORDER + # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: diff --git a/testsuite/modules.00-init/010-environ.exp b/testsuite/modules.00-init/010-environ.exp index db0a2a5a1..42932b45a 100644 --- a/testsuite/modules.00-init/010-environ.exp +++ b/testsuite/modules.00-init/010-environ.exp @@ -188,6 +188,9 @@ catch {unset env(MODULES_COLLECTION_TARGET)} catch {unset env(MODULE_VERSION)} catch {unset env(MODULE_VERSION_STACK)} +# ensure that tests doesn't run with Lmod path order +unsetenv_var MODULES_PATH_ENTRY_REORDER + set env(MODULERCFILE) "$env(TESTSUITEDIR)/etc/empty" set ORIG_MODULERCFILE $env(MODULERCFILE) catch {unset env(MODULESHOME)} diff --git a/testsuite/modules.70-maint/220-config.exp b/testsuite/modules.70-maint/220-config.exp index 6a55b7dc8..2068d0043 100644 --- a/testsuite/modules.70-maint/220-config.exp +++ b/testsuite/modules.70-maint/220-config.exp @@ -93,6 +93,7 @@ array set configdfl [list\ ml [expr {$install_ml eq {y}}]\ nearly_forbidden_days $install_nearlyforbiddendays\ pager "$install_pagercmd"\ + path_entry_reorder [expr {$install_pathentryreorder eq {y}}]\ protected_envvars \ quarantine_support [expr {$install_quarantinesupport eq {y}}]\ rcfile \ @@ -158,6 +159,7 @@ array set configvar [list\ ml MODULES_ML\ nearly_forbidden_days MODULES_NEARLY_FORBIDDEN_DAYS\ pager MODULES_PAGER\ + path_entry_reorder MODULES_PATH_ENTRY_REORDER\ protected_envvars MODULES_PROTECTED_ENVVARS\ quarantine_support MODULES_QUARANTINE_SUPPORT\ rcfile MODULERCFILE\ @@ -213,6 +215,7 @@ array set configvalid [list\ mcookie_version_check {0 1}\ ml {0 1}\ nearly_forbidden_days {0 365}\ + path_entry_reorder {0 1}\ quarantine_support {0 1}\ redirect_output {0 1}\ require_via {0 1}\ From fb65540800b0cd46a2fcb267502e2cbf7372d758 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 18 Dec 2025 14:44:27 +0100 Subject: [PATCH 21/25] setting default value for path_entry_reorder fixed Signed-off-by: Achim Gsell --- Makefile | 8 +++++++- tcl/init.tcl.in | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 90c363a46..abc2dca3e 100644 --- a/Makefile +++ b/Makefile @@ -395,6 +395,12 @@ else setwa277 := 0 endif +ifeq ($(pathentryreorder),y) + setpathentryreorder := 1 +else + setpathentryreorder := 0 +endif + ifneq ($(tcllinteropts),) tcllintercmd := $(tcllinter) $(tcllinteropts) else @@ -443,7 +449,7 @@ sed -e 's|@prefix@|$(prefix)|g' \ -e 's|@sourcecache@|$(setsourcecache)|g' \ -e 's|@searchmatch@|$(searchmatch)|g' \ -e 's|@wa277@|$(setwa277)|g' \ - -e 's|@pathentryreorder@|$(pathentryreorder)|g' \ + -e 's|@pathentryreorder@|$(setpathentryreorder)|g' \ -e 's|@icase@|$(icase)|g' \ -e 's|@nearlyforbiddendays@|$(nearlyforbiddendays)|g' \ -e 's|@tagabbrev@|$(tagabbrev)|g' \ diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in index bae1e83ce..a438a6567 100644 --- a/tcl/init.tcl.in +++ b/tcl/init.tcl.in @@ -122,7 +122,7 @@ array set g_config_defs [list\ nearly_forbidden_days {MODULES_NEARLY_FORBIDDEN_DAYS @nearlyforbiddendays@\ 0 i {0 365} {} {} intbe}\ pager {MODULES_PAGER {@pagercmd@} 0 s}\ - path_entry_reorder {MODULES_PATH_ENTRY_REORDER @pathentryreorder@ 0 0 b {0 1}}\ + path_entry_reorder {MODULES_PATH_ENTRY_REORDER @pathentryreorder@ 0 b {0 1}}\ protected_envvars {MODULES_PROTECTED_ENVVARS 0 l}\ rcfile {MODULERCFILE 0 l}\ redirect_output {MODULES_REDIRECT_OUTPUT 1 0 b {0 1}}\ From 4ff70bf12c3d36e5b859bb7a1229bb646e4dfb52 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 7 Jan 2026 16:55:03 +0100 Subject: [PATCH 22/25] append/prepend tests added Signed-off-by: Achim Gsell --- testsuite/modules.50-cmds/040-append.exp | 91 ++++++++++++++++++++++- testsuite/modules.50-cmds/050-prepend.exp | 39 +++++++++- 2 files changed, 125 insertions(+), 5 deletions(-) diff --git a/testsuite/modules.50-cmds/040-append.exp b/testsuite/modules.50-cmds/040-append.exp index eade6e4e7..47c78b04b 100644 --- a/testsuite/modules.50-cmds/040-append.exp +++ b/testsuite/modules.50-cmds/040-append.exp @@ -165,6 +165,7 @@ testouterr_cmd "sh" "load $module" $ans "" set module "append/4.0" set modulefile "$modpath/$module" +setenv_var MODULES_PATH_ENTRY_REORDER 0 unsetenv_path_var FOO set env(__MODULES_SHARE_BAR) "/path/to/dir1:2" set env(BAR) "/path/to/dir1:/path/to/dir2:/path/to/dir1" @@ -179,6 +180,22 @@ lappend ans [list set LOADEDMODULES $module] testouterr_cmd "sh" "load $module" $ans "" +setenv_var MODULES_PATH_ENTRY_REORDER 1 +unsetenv_path_var FOO +set env(__MODULES_SHARE_BAR) "/path/to/dir1:2" +set env(BAR) "/path/to/dir1:/path/to/dir2:/path/to/dir1" + +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO "/path/to/dir1:2"] +lappend ans [list set FOO "/path/to/dir1:/path/to/dir2:/path/to/dir1"] +lappend ans [list set __MODULES_SHARE_BAR "/path/to/dir1:3"] +lappend ans [list set BAR "/path/to/dir2:/path/to/dir1"] +lappend ans [list set _LMFILES_ $modulefile] +lappend ans [list set LOADEDMODULES $module] + +testouterr_cmd "sh" "load $module" $ans "" + +setenv_var MODULES_PATH_ENTRY_REORDER 0 set env(FOO) "/path/to/dir1" set ans [list] @@ -191,6 +208,20 @@ lappend ans [list set LOADEDMODULES $module] testouterr_cmd "sh" "load $module" $ans "" +setenv_var MODULES_PATH_ENTRY_REORDER 1 +set env(FOO) "/path/to/dir1" + +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO "/path/to/dir1:3"] +lappend ans [list set FOO "/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1"] +lappend ans [list set __MODULES_SHARE_BAR "/path/to/dir1:3"] +lappend ans [list set BAR "/path/to/dir2:/path/to/dir1"] +lappend ans [list set _LMFILES_ $modulefile] +lappend ans [list set LOADEDMODULES $module] + +testouterr_cmd "sh" "load $module" $ans "" + +setenv_var MODULES_PATH_ENTRY_REORDER 0 set env(__MODULES_SHARE_FOO) "/path/to/dir1:2" set env(FOO) "/path/to/dir1" @@ -204,6 +235,23 @@ lappend ans [list set LOADEDMODULES $module] testouterr_cmd "sh" "load $module" $ans "" +setenv_var MODULES_PATH_ENTRY_REORDER 1 +set env(__MODULES_SHARE_FOO) "/path/to/dir1:2" +set env(FOO) "/path/to/dir1" + +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO "/path/to/dir1:4"] +lappend ans [list set FOO "/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1"] +lappend ans [list set __MODULES_SHARE_BAR "/path/to/dir1:3"] +lappend ans [list set BAR "/path/to/dir2:/path/to/dir1"] +lappend ans [list set _LMFILES_ $modulefile] +lappend ans [list set LOADEDMODULES $module] + +testouterr_cmd "sh" "load $module" $ans "" + +# reset to default config +unset env(MODULES_PATH_ENTRY_REORDER) + # test unload mode on append-path --duplicates setenv_loaded_module [list $module] [list $modulefile] set ans [list] @@ -228,15 +276,16 @@ lappend ans [list unset _LMFILES_] lappend ans [list unset LOADEDMODULES] testouterr_cmd sh "unload $module" $ans {} +set module "append/4.1" +set modulefile "$modpath/$module" + +setenv_var MODULES_PATH_ENTRY_REORDER 0 setenv_var FOO /path/to/dir1 setenv_var __MODULES_SHARE_FOO /path/to/dir1:2 setenv_var BAR /path/to/dir1:/path/to/dir2:/path/to/dir1 setenv_var __MODULES_SHARE_BAR /path/to/dir1:2 unsetenv_loaded_module -set module "append/4.1" -set modulefile "$modpath/$module" - set ans [list] lappend ans [list set __MODULES_SHARE_FOO "/path/to/dir1:4"] lappend ans [list set FOO "/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1"] @@ -247,6 +296,25 @@ lappend ans [list set LOADEDMODULES $module] testouterr_cmd "sh" "load $module" $ans [msg_load $module "$warn_msgs: --index option has no effect on append-path"] +setenv_var MODULES_PATH_ENTRY_REORDER 1 +setenv_var FOO /path/to/dir1 +setenv_var __MODULES_SHARE_FOO /path/to/dir1:2 +setenv_var BAR /path/to/dir1:/path/to/dir2:/path/to/dir1 +setenv_var __MODULES_SHARE_BAR /path/to/dir1:2 +unsetenv_loaded_module + +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO "/path/to/dir1:4"] +lappend ans [list set FOO "/path/to/dir1:/path/to/dir1:/path/to/dir2:/path/to/dir1"] +lappend ans [list set __MODULES_SHARE_BAR "/path/to/dir1:3"] +lappend ans [list set BAR "/path/to/dir2:/path/to/dir1"] +lappend ans [list set _LMFILES_ $modulefile] +lappend ans [list set LOADEDMODULES $module] + +testouterr_cmd "sh" "load $module" $ans [msg_load $module "$warn_msgs: --index option has no effect on append-path"] + +# reset to default config +unset env(MODULES_PATH_ENTRY_REORDER) # test setting a large value in variable. For csh shell family, Modules # truncates value to avoid going over csh limit (this should be changed in @@ -297,6 +365,7 @@ testouterr_cmd_re "csh" "load $module" $ans $ts_err set module "append/6.0" set modulefile "$modpath/$module" +setenv_var MODULES_PATH_ENTRY_REORDER 0 set env(__MODULES_SHARE_FOO) "/path/to/dir3:2" set env(FOO) "/path/to/dir1:/path/to/dir4" @@ -309,6 +378,22 @@ lappend ans [list set LOADEDMODULES $module] # reference counter is automatically adjusted testouterr_cmd "sh" "load $module" $ans {} +setenv_var MODULES_PATH_ENTRY_REORDER 1 +set env(__MODULES_SHARE_FOO) "/path/to/dir3:2" +set env(FOO) "/path/to/dir1:/path/to/dir4" + +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO "/path/to/dir1:2"] +lappend ans [list set FOO "/path/to/dir4:/path/to/dir1:/path/to/dir2"] +lappend ans [list set _LMFILES_ $modulefile] +lappend ans [list set LOADEDMODULES $module] + +# reference counter is automatically adjusted +testouterr_cmd "sh" "load $module" $ans {} + +# reset to default config +unset env(MODULES_PATH_ENTRY_REORDER) + # test incoherent state on unload mode setenv_loaded_module $module $modulefile set ans [list] diff --git a/testsuite/modules.50-cmds/050-prepend.exp b/testsuite/modules.50-cmds/050-prepend.exp index e29a8d34d..99464789f 100644 --- a/testsuite/modules.50-cmds/050-prepend.exp +++ b/testsuite/modules.50-cmds/050-prepend.exp @@ -151,14 +151,13 @@ lappend ans [list set LOADEDMODULES $module] lappend ans [list set testsuite --delim=,:http://foobar.com] testouterr_cmd_re "sh" "load $module" $ans {} - # # Try prepending empty string and check reference counter # - set module "prepend/3.0" set modulefile "$modpath/$module" +setenv_var MODULES_PATH_ENTRY_REORDER 0 set ans [list] lappend ans [list set __MODULES_SHARE_FOO ":1"] lappend ans [list set FOO ""] @@ -192,6 +191,42 @@ lappend ans [list set LOADEDMODULES "$module2:$module"] testouterr_cmd_re "sh" "load $module2 $module" $ans "" +setenv_var MODULES_PATH_ENTRY_REORDER 1 +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO ":1"] +lappend ans [list set FOO ""] +lappend ans [list set _LMFILES_ $modulefile] +lappend ans [list set LOADEDMODULES $module] + +testouterr_cmd "sh" "load $module" $ans "" + +# empty var does not always mean empty path entry set, only if a corresponding +# reference counter array entry can be found +set env(FOO) "" +testouterr_cmd "sh" "load $module" $ans "" + +unset env(FOO) +set module2 "prepend/3.1" +set modulefile2 "$modpath/$module2" + +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO ":2"] +lappend ans [list set FOO "/path/to/dir:"] +lappend ans [list set _LMFILES_ "$modulefile:$modulefile2"] +lappend ans [list set LOADEDMODULES "$module:$module2"] + +testouterr_cmd_re "sh" "load $module $module2" $ans "" + +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO ":2"] +lappend ans [list set FOO ":/path/to/dir"] +lappend ans [list set _LMFILES_ "$modulefile2:$modulefile"] +lappend ans [list set LOADEDMODULES "$module2:$module"] + +testouterr_cmd_re "sh" "load $module2 $module" $ans "" + +# reset to default config +unset env(MODULES_PATH_ENTRY_REORDER) # # Prepending multiple paths passed as one string From e677e7053b796373ce964452a8594c1c7c2beb29 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 8 Jan 2026 10:15:57 +0100 Subject: [PATCH 23/25] --enable-path-entry-reoder added to tcl85-2 config opts Signed-off-by: Achim Gsell --- .github/workflows/linux_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux_tests.yaml b/.github/workflows/linux_tests.yaml index 86d9544bb..928cb699a 100644 --- a/.github/workflows/linux_tests.yaml +++ b/.github/workflows/linux_tests.yaml @@ -132,7 +132,7 @@ jobs: tcl85-2: runs-on: ubuntu-22.04 env: - CONFIGURE_OPTS: --with-tclsh=tclsh8.5 --prefix=/tmp/modules --with-tcl=/usr/local/lib --enable-quarantine-support --enable-silent-shell-debug-support --enable-modulespath --with-pager=more --with-dark-background-colors=hi --with-locked-configs=implicit_default --enable-wa-277 --enable-advanced-version-spec --disable-ml --disable-implicit-requirement --enable-set-shell-startup + CONFIGURE_OPTS: --with-tclsh=tclsh8.5 --prefix=/tmp/modules --with-tcl=/usr/local/lib --enable-quarantine-support --enable-silent-shell-debug-support --enable-modulespath --with-pager=more --with-dark-background-colors=hi --with-locked-configs=implicit_default --enable-wa-277 --enable-advanced-version-spec --disable-ml --disable-implicit-requirement --enable-set-shell-startup --enable-path-entry-reorder COVERAGE: y EXTRA_SCRIPT_PRETEST: make install-testinitrc-1 install-testetcrc install-testmodspath EXTRA_SCRIPT_POSTTEST: make uninstall-testconfig From 38df309378662120d3beb3008c39c8bef59a15a8 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 8 Jan 2026 13:03:58 +0100 Subject: [PATCH 24/25] documentation fixed Signed-off-by: Achim Gsell --- doc/source/module.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/module.rst b/doc/source/module.rst index e63f8041f..797ec87f2 100644 --- a/doc/source/module.rst +++ b/doc/source/module.rst @@ -1377,7 +1377,7 @@ Module Sub-Commands a path entry that is already defined in the environment variable. Default value is ``0``. It can be changed at installation time with the - :instopt:`--with-path-entry-reorder` option. The + :instopt:`--enable-path-entry-reorder` option. The :envvar:`MODULES_PATH_ENTRY_REORDER` environment variable is defined by :subcmd:`config` sub-command when changing this configuration option from its default value. See :envvar:`MODULES_PATH_ENTRY_REORDER` description @@ -1385,7 +1385,7 @@ Module Sub-Commands .. only:: html - .. versionadded:: 5.x + .. versionadded:: 5.7 .. mconfig:: protected_envvars @@ -5318,7 +5318,7 @@ ENVIRONMENT .. only:: html - .. versionadded:: 5.x + .. versionadded:: 5.7 .. envvar:: MODULES_PROTECTED_ENVVARS From 580b375b9cc6566dd6ae6c60dea6772a34b82fbb Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 8 Jan 2026 13:38:06 +0100 Subject: [PATCH 25/25] test for path_entry_reorder added Signed-off-by: Achim Gsell --- testsuite/modulefiles/append/9.0 | 24 ++++++++++++++++++++++++ testsuite/modules.50-cmds/040-append.exp | 20 ++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 testsuite/modulefiles/append/9.0 diff --git a/testsuite/modulefiles/append/9.0 b/testsuite/modulefiles/append/9.0 new file mode 100644 index 000000000..b22032e1c --- /dev/null +++ b/testsuite/modulefiles/append/9.0 @@ -0,0 +1,24 @@ +#%Module1.0 + +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: append/%M% +# Revision: %I% +# First Edition: 2026/01/08 +# Last Mod.: %U%, %G% +# +# Authors: Achim Gsell, achim.gsell@psi.ch +# +# Description: Test appending paths with path_entry_enabled +# Command: +# Sub-Command: append-path +# +# Invocation: load @M@/@V@ +# Comment: %C{ +# }C% +# +############################################################################## + +append-path FOO /test/dir1 /test/dir2 /test/dir3 diff --git a/testsuite/modules.50-cmds/040-append.exp b/testsuite/modules.50-cmds/040-append.exp index 47c78b04b..c250e2817 100644 --- a/testsuite/modules.50-cmds/040-append.exp +++ b/testsuite/modules.50-cmds/040-append.exp @@ -485,6 +485,26 @@ lappend ans [list unset LOADEDMODULES] testouterr_cmd "sh" "unload $module" $ans {} +# +# test that path entry is not removed if added twice and path_entry_reorder +# is true +# +set module "append/9.0" +set modulefile "$modpath/$module" + +setenv_var MODULES_PATH_ENTRY_REORDER 1 +setenv_var FOO /test/dir2 +unsetenv_var __MODULES_SHARE_FOO + +unsetenv_loaded_module +set ans [list] +lappend ans [list set __MODULES_SHARE_FOO "/test/dir2:2"] +lappend ans [list set FOO "/test/dir1:/test/dir2:/test/dir3"] +lappend ans [list set _LMFILES_ $modulefile] +lappend ans [list set LOADEDMODULES $module] + +testouterr_cmd "sh" "load $module" $ans "" + # # --glob option #