I've found a bug (or at best a very perverse "feature") in zsh; it
can be illustrated by the following three short scripts:
# script_A
PATH=/usr/local/bin:/usr/bin:/bin
echo $#path
typeset -U path
echo $#path
# eof
# script_B
source script_A
# eof
# script_C
c_fxn () { source script_A }
c_fxn
# eof
Note that both the contents of script_B and the body of the function
c_fxn defined in script_C consist of the same one line, namely
"source script_A". Now,
% source script_B
3
3
% source script_C
3
0
In words, when script_A is sourced within a script that is itself
being sourced, typeset -U path preserves the components of PATH
(or at least their number), but if script_A is sourced within the
body of a *function*, calling the function causes the expression
typeset -U path to *clear* the contents of PATH.
Please-please-please don't tell me this is a feature! I'd lose
all faith in the designers of zsh if this turns out to be a feature!
More importantly, how does one get around this problem. I've tried
saving the value of $path before calling 'typeset -U' on it, and
restoring it afterwards, but the results have been disastrous (I've
tried too many variants to describe them all).
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.