Skip to content

Commit 39923ad

Browse files
committed
Revert "init: setup zsh FPATH through autoinit command"
This reverts commit 59ac24e. FPATH variable cannot be handled within autoinit process as this is not an environment variable. Thus when modulecmd.tcl is executed, it does not know the current value of FPATH. So if it sets FPATH during autoinit, previous value of this variable is lost. As a result FPATH must stay defined in initialization script.
1 parent 52fda47 commit 39923ad

File tree

6 files changed

+20
-54
lines changed

6 files changed

+20
-54
lines changed

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,6 @@ else
232232
setusemanpath := \#
233233
setnotusemanpath :=
234234
endif
235-
ifeq ($(zshcompletiondir),)
236-
setzshfpath :=
237-
else
238-
setzshfpath := \#
239-
endif
240235

241236
# build list of shell whose completion script has to be sourced during
242237
# autoinit initialization
@@ -423,7 +418,6 @@ sed -e 's|@prefix@|$(prefix)|g' \
423418
-e 's|@usemanpath@|$(setusemanpath)|g' \
424419
-e 's|@notusemanpath@|$(setnotusemanpath)|g' \
425420
-e 's|@shellcompsource@|$(shellcompsource)|g' \
426-
-e 's|@setzshfpath@|$(setzshfpath)|g' \
427421
-e 's|@tcllintercmd@|$(tcllintercmd)|g' \
428422
-e 's|@nagelfaraddons@|$(setnagelfaraddons)|g' \
429423
-e 's|@MODULES_RELEASE@|$(MODULES_RELEASE)|g' \

NEWS.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ Modules 5.2.0 (not yet released)
3535
issue #462)
3636
* Init: move shell completion setup from shell initialization scripts to the
3737
:subcmd:`autoinit` sub-command. (fix issue #462)
38-
* Init: move zsh :envvar:`FPATH` setup (to locate Modules' functions) from
39-
shell initialization scripts to the :subcmd:`autoinit` sub-command. (fix
40-
issue #462)
4138
* Enclose installation path references in shell code produced by
4239
:subcmd:`autoinit`, in initialization scripts and Makefiles to guaranty
4340
correct evaluation in case these paths contain a space character. Note that

init/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ else
8787
endif
8888
ifeq ($(zshcompletiondir),)
8989
zshcompletiondir := $(initdir)/zsh-functions
90+
setzshfpathre := s|@setzshfpath@||g
91+
else
92+
setzshfpathre := /@setzshfpath@/d
9093
endif
9194

9295
# comment entries if feature not enabled
@@ -161,6 +164,7 @@ sed -e 's|@prefix@|$(prefix)|g' \
161164
-e 's|@comp_path_opts@|$(comp_path_opts)|g' \
162165
-e 's|@comp_rm_path_opts@|$(comp_rm_path_opts)|g' \
163166
-e 's|@comp_config_opts@|$(comp_config_opts)|g' \
167+
-e '$(setzshfpathre)' \
164168
-e $$'s|@modulerc@|$(modulerc)|g' \
165169
-e 's|@modulepath@|$(modulepath)|g' \
166170
-e '$(setquarvarsre)' $(quarvarsre) \

init/zsh.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ fi;
3636

3737
# define module command and surrounding initial environment (default value
3838
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init config files)
39-
eval "$(${^^=_mlre:-}@TCLSH@ '@libexecdir@/modulecmd.tcl' zsh autoinit)"
39+
_mlcode=$(${^^=_mlre:-}@TCLSH@ '@libexecdir@/modulecmd.tcl' zsh autoinit)
40+
_mlret=$?
4041

4142
# clean temp variables used to setup quarantine
4243
if [ -n "${_mlIFS+x}" ]; then
@@ -47,6 +48,19 @@ else
4748
fi;
4849
unset _mlre _mlv _mlrv
4950

51+
# no environment alteration if the above autoinit command failed
52+
if [ $_mlret -eq 0 ]; then
53+
eval "$_mlcode"
54+
@setzshfpath@
55+
@setzshfpath@ # setup FPATH to put module completion at hand in case zsh completion enabled
56+
@setzshfpath@ # cannot be configured by autoinit as FPATH is not an environment variable
57+
@setzshfpath@ if [[ ! ":$FPATH:" =~ ':@initdir@/zsh-functions:' ]]; then
58+
@setzshfpath@ FPATH="@initdir@/zsh-functions${FPATH:+:}$FPATH"
59+
@setzshfpath@ fi
60+
fi
61+
62+
unset _mlcode _mlret
63+
5064
# restore shell debugging options if disabled
5165
if [ -n "${_mlshdbg:-}" ]; then
5266
set -$_mlshdbg;

tcl/subcmd.tcl.in

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,13 +2005,6 @@ proc cmdModuleAutoinit {} {
20052005
}
20062006
}
20072007

2008-
if {[getState shell] eq {zsh}} {
2009-
# setup FPATH to put module completion at hand when zsh completion
2010-
# script is not installed in default completion location
2011-
##nagelfar ignore Too long line
2012-
@setzshfpath@prepend-path --ignore-refcount FPATH {@initdir@/zsh-functions}
2013-
}
2014-
20152008
# clear in progress flag
20162009
unsetenv __MODULES_AUTOINIT_INPROGRESS
20172010

testsuite/modules.70-maint/120-autoinit.exp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,6 @@ foreach set_shell_startup [list {} 0 1] {
756756
lappend ans [list set BASH_ENV $install_initdir/bash]
757757
}
758758
lappend ans [list set MODULESHOME $moduleshome]
759-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
760-
lappend ans [list set FPATH $install_zshcompletiondir]
761-
}
762759
if {$shell eq {ksh}} {
763760
lappend ans [list set FPATH $install_initdir/ksh-functions]
764761
}
@@ -782,9 +779,6 @@ foreach set_shell_startup [list {} 0 1] {
782779
lappend ans [list set BASH_ENV $install_initdir/bash]
783780
}
784781
lappend ans [list set MODULESHOME $moduleshome]
785-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
786-
lappend ans [list set FPATH $install_zshcompletiondir]
787-
}
788782
if {$shell eq {ksh}} {
789783
lappend ans [list set FPATH $install_initdir/ksh-functions]
790784
}
@@ -1020,16 +1014,13 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
10201014
set ans [list]
10211015
lappend ans [list [set "func_$shell"]]
10221016
if {!$insmodspath && !$insmodrc} {
1023-
if {$shell in {ksh zsh} && $install_versioning eq "y"} {
1017+
if {$shell eq {ksh} && $install_versioning eq "y"} {
10241018
if {$change_manpath} {
10251019
lappend ans [list set MANPATH $updatedmanpath]
10261020
}
10271021
lappend ans [list set LOADEDMODULES ""]
10281022
lappend ans [list set MODULESHOME $moduleshome]
10291023
lappend ans [list set MODULE_VERSION "(.*)"]
1030-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1031-
lappend ans [list set FPATH $install_zshcompletiondir]
1032-
}
10331024
if {$shell eq {ksh}} {
10341025
lappend ans [list set FPATH $install_initdir/ksh-functions]
10351026
}
@@ -1075,9 +1066,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
10751066
}
10761067
lappend ans [list set MODULESHOME $moduleshome]
10771068
lappend ans [list set LOADEDMODULES ""]
1078-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1079-
lappend ans [list set FPATH $install_zshcompletiondir]
1080-
}
10811069
if {$shell eq {ksh}} {
10821070
lappend ans [list set FPATH $install_initdir/ksh-functions]
10831071
}
@@ -1098,9 +1086,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
10981086
if {$install_versioning eq "y"} {
10991087
lappend ans [list set MODULE_VERSION_STACK "(.*)"]
11001088
}
1101-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1102-
lappend ans [list set FPATH $install_zshcompletiondir]
1103-
}
11041089
if {$shell eq {ksh} || $shell eq {sh} || $shell eq {bash}} {
11051090
lappend ans [list set FPATH $install_initdir/ksh-functions]
11061091
}
@@ -1133,9 +1118,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
11331118
lappend ans [list unset __MODULES_AUTOINIT_INPROGRESS]
11341119
lappend ans [list set _LMFILES_ "$install_modulefilesdir/null"]
11351120
lappend ans [list set MODULESHOME $moduleshome/init]
1136-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1137-
lappend ans [list set FPATH $install_zshcompletiondir]
1138-
}
11391121
lappend ans [list set LOADEDMODULES null]
11401122
if {$shell eq {ksh} || $shell eq {sh} || $shell eq {bash}} {
11411123
lappend ans [list set FPATH $install_initdir/ksh-functions]
@@ -1170,9 +1152,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
11701152
}
11711153
lappend ans [list set MODULESHOME $moduleshome]
11721154
lappend ans [list set LOADEDMODULES ""]
1173-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1174-
lappend ans [list set FPATH $install_zshcompletiondir]
1175-
}
11761155
if {$shell eq {ksh}} {
11771156
lappend ans [list set FPATH $install_initdir/ksh-functions]
11781157
}
@@ -1208,9 +1187,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
12081187
if {$shell eq {ksh}} {
12091188
lappend ans [list set FPATH $install_initdir/ksh-functions]
12101189
}
1211-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1212-
lappend ans [list set FPATH $install_zshcompletiondir]
1213-
}
12141190
lappend ans [list set __MODULES_LMINIT $lminit_modrc_exinstalled]
12151191
lappend ans [list set MODULEPATH "$install_modulepath"]
12161192
if {$install_versioning eq "y"} {
@@ -1229,9 +1205,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
12291205
if {$shell eq {ksh} || $shell eq {sh} || $shell eq {bash}} {
12301206
lappend ans [list set FPATH $install_initdir/ksh-functions]
12311207
}
1232-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1233-
lappend ans [list set FPATH $install_zshcompletiondir]
1234-
}
12351208
lappend ans [list set MODULES_CMD $modulecmd_path]
12361209
if {$shell in {sh bash ksh zsh csh tcsh fish} && $change_manpath} {
12371210
if {$extra_sysmanpath} {
@@ -1267,9 +1240,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
12671240
lappend ans [list unset __MODULES_AUTOINIT_INPROGRESS]
12681241
lappend ans [list set _LMFILES_ "$install_modulefilesdir/null"]
12691242
lappend ans [list set MODULESHOME $moduleshome/init]
1270-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1271-
lappend ans [list set FPATH $install_zshcompletiondir]
1272-
}
12731243
lappend ans [list set LOADEDMODULES null]
12741244
if {$shell eq {ksh} || $shell eq {sh} || $shell eq {bash}} {
12751245
lappend ans [list set FPATH $install_initdir/ksh-functions]
@@ -1302,9 +1272,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
13021272
}
13031273
lappend ans [list unset __MODULES_AUTOINIT_INPROGRESS]
13041274
lappend ans [list set MODULESHOME $moduleshome]
1305-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1306-
lappend ans [list set FPATH $install_zshcompletiondir]
1307-
}
13081275
lappend ans [list set __MODULES_LMPREREQ m3&m1]
13091276
lappend ans [list set _LMFILES_ "$modpath.deps/m1:$modpath.deps/m3:$modpath wspace/space yc/4"]
13101277
lappend ans [list set LOADEDMODULES "m1:m3:space yc/4"]
@@ -1325,9 +1292,6 @@ if {(!$insmodspath || $modspath_exinstalled) && (!$insmodrc || $modrc_exinstalle
13251292
lappend ans [list set __MODULES_LMPREREQ m3&m1]
13261293
lappend ans [list set _LMFILES_ "$modpath.deps/m1:$modpath.deps/m3:$modpath wspace/space yc/4"]
13271294
lappend ans [list set LOADEDMODULES "m1:m3:space yc/4"]
1328-
if {$shell eq {zsh} && $install_setzshfpath eq {y}} {
1329-
lappend ans [list set FPATH $install_zshcompletiondir]
1330-
}
13311295
lappend ans [list set __MODULES_LMINIT $lminit_initrc_exinstalled]
13321296
lappend ans [list set __MODULES_LMTAG m1&auto-loaded]
13331297
lappend ans [list set MODULEPATH "$modpath wspace:$modpath.deps"]

0 commit comments

Comments
 (0)