From 15731e61bb095d91a6a8678173b2832e92dbfb2e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 29 Oct 2025 12:51:06 +0100 Subject: [PATCH 01/13] follow Lmod rules for path updates --- 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 80cab3527..4fc3a2feb 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1815,17 +1815,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)]} { @@ -2054,7 +2069,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 9becb4eaf..2dc977b07 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -1965,7 +1965,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 @@ -3148,7 +3157,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 041b33a1fe1b1cc602a0ca4ea98a584fe8475916 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 29 Oct 2025 13:38:23 +0100 Subject: [PATCH 02/13] code not belonging to this PR removed --- 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 2dc977b07..fcd98ff03 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -1965,16 +1965,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 9f5864b9e2250666f3cd2da5b4495c5f30859a4e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 29 Oct 2025 13:40:20 +0100 Subject: [PATCH 03/13] untabify --- 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 fcd98ff03..9c51803e0 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -1965,7 +1965,7 @@ proc runModuleUse {cmd mode pos args} { $* { lappend pathlist $path } - default { + default { if {$pos eq {remove}} { if {$path in $modpathlist} { lappend pathlist $path From cf424aaddab62b7e4009214cd02ee5d43f73c6ab Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 16:05:59 +0100 Subject: [PATCH 04/13] config option renamed and add-path reviewed --- 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 4fc3a2feb..27eb7ce78 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1796,7 +1796,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 } @@ -1815,33 +1815,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 @@ -2069,8 +2065,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 37ed41b1cf19a2f656afa33806330f2aa780a980 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 16:55:49 +0100 Subject: [PATCH 05/13] configure fixed --- 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 76b8dea3c3ac8c0ec9a9c75a338ab57169cf3913 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 17:28:56 +0100 Subject: [PATCH 06/13] comments added to make design more clear --- 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 27eb7ce78..e332961c5 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1816,14 +1816,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 8b0e5d1fd9d9c7dc5e2f5257bebe78b20d11b157 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Nov 2025 17:38:53 +0100 Subject: [PATCH 07/13] Emacs local variables fixed --- 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 9c51803e0..4205a5011 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -3148,8 +3148,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 101ed8a2ba53feb3b9879ab3819699ef02cf7d47 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 10 Nov 2025 13:28:56 +0100 Subject: [PATCH 08/13] substitution for pathentryreorder added to Makefile --- 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 6d8e491a7725d47565880c5aa651553c0644dd0f Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 10 Nov 2025 13:30:41 +0100 Subject: [PATCH 09/13] Option --enable-path-entry-reoder fixed --- 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 7bf3a1953f236cfec03f77003088f6cdb92991df Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Mon, 10 Nov 2025 13:32:35 +0100 Subject: [PATCH 10/13] Use @pathentryreorder@ to set default --- 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 ddc1d4ad5ac43ec8c60f6bd0ebbd7648c76b9673 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 12 Nov 2025 14:27:51 +0100 Subject: [PATCH 11/13] configuration option property fixed for path_entry_reorder --- 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 5964cebe40a1d15b2da7a437ced206ebc4dfc475 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 12 Nov 2025 15:12:41 +0100 Subject: [PATCH 12/13] revised code if path_entry_reoder is set --- 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 e332961c5..7805c21e0 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1816,47 +1816,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 e48dea7988659d35a95987aeac26aee52b272bb9 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 12 Nov 2025 15:31:09 +0100 Subject: [PATCH 13/13] untabify --- 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 7805c21e0..51fa9f674 100644 --- a/tcl/envmngt.tcl.in +++ b/tcl/envmngt.tcl.in @@ -1796,7 +1796,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 }