@@ -1796,7 +1796,7 @@ proc add-path {cmd mode dflbhv args} {
17961796 set bhv $dflbhv
17971797 } else {
17981798 lassign [parsePathCommandArgs $cmd $mode $dflbhv {*}$args ] separator\
1799- allow_dup idx_val ign_refcount val_set_is_delim glob_match bhv var\
1799+ allow_dup idx_val ign_refcount val_set_is_delim glob_match bhv var\
18001800 path_list
18011801 }
18021802
@@ -1815,33 +1815,29 @@ proc add-path {cmd mode dflbhv args} {
18151815
18161816 set val [get-env $var ]
18171817
1818- if {[getConf lmod_path_rule]} {
1819- set mpath_list [split $val $separator ]
1820- foreach dir $path_list {
1821- if {$bhv eq {prepend}} {
1822- set mpath_list " $dir [ lsearch -inline -all -not -exact\
1823- $mpath_list $dir ] "
1824- } else {
1825- set mpath_list " [ lsearch -inline -all -not -exact\
1826- $mpath_list $dir ] $dir "
1818+ foreach dir $path_list {
1819+ set dir_removed 0
1820+ if {[getConf path_entry_reorder]} {
1821+ if {[info exists countarr($dir )] && ! $allow_dup } {
1822+ # remove dir if in $val and duplicates are not allowed
1823+ set mpath_list [split $val $separator ]
1824+ set mpath_list [lsearch -inline -all -not -exact $mpath_list $dir ]
1825+ set val [join $mpath_list $separator ]
1826+ set countarr($dir ) 0
1827+ set dir_removed 1
18271828 }
1828- set val [join $mpath_list $separator ]
18291829 }
1830- set countarr($dir ) 1
1831- } else {
1832- foreach dir $path_list {
1833- if {![info exists countarr($dir )] || $allow_dup } {
1834- # ignore env var set empty if no empty entry found in reference
1835- # counter array (sometimes var is cleared by setting it empty not
1836- # unsetting it)
1837- if {$val ne {} || [info exists countarr()]} {
1838- set sep [expr {$val eq $separator ? {} : $separator }]
1839- set val [expr {$bhv eq {prepend} ? " $dir$sep$val " :\
1840- " $val$sep$dir " }]
1830+ if {![info exists countarr($dir )] || $dir_removed || $allow_dup } {
1831+ # ignore env var set empty if no empty entry found in reference
1832+ # counter array (sometimes var is cleared by setting it empty not
1833+ # unsetting it)
1834+ if {$val ne {} || [info exists countarr()]} {
1835+ set sep [expr {$val eq $separator ? {} : $separator }]
1836+ set val [expr {$bhv eq {prepend} ? " $dir$sep$val " :\
1837+ " $val$sep$dir " }]
18411838 } else {
18421839 set val $dir
18431840 }
1844- }
18451841 }
18461842 if {[info exists countarr($dir )]} {
18471843 # do not increase counter if bare separator string is added or if
@@ -2069,8 +2065,10 @@ proc getModulesEnvVarGlobList {{loaded_ctx 0}} {
20692065 return $envvar_glob_list
20702066}
20712067
2072- # Local Variables:
2073- # Mode: tcl-mode
2074- # tcl-indent-level: 3
2075- # End:
2068+ # ;;; Local Variables:
2069+ # ;;; Mode: tcl-mode
2070+ # ;;; tcl-indent-level: 3
2071+ # ;;; tcl-continued-indent-level: 3
2072+ # ;;; indent-tabs-mode: nil
2073+ # ;;; End:
20762074# vim:set tabstop=3 shiftwidth=3 expandtab autoindent:
0 commit comments