Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Parameter expansion



The zsh manual says regarding to parameter expansion:

  ${+name} 
    If name is the name of a set parameter `1' is substituted, otherwise `0' is
    substituted.

But why do I do get the following than?

% if [ ! ${+BLURB} ]; then
then> echo "BLURB not set"
then> else
else> echo "BLURB set"
else> fi
BLURB set
% 

I was expecting the opposite. Curiously:


% export BLURB=foo
% if [ ! ${+BLURB} ]; then
echo "BLURB not set"
else
echo "BLURB set"
fi
BLURB set
%

Maybe the question should be: How do you check whether or not an
environment variable is set?

Comments are appreciated.

	Roland



Messages sorted by: Reverse Date, Date, Thread, Author