Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: [[ -v varname ]]
On 2016-09-15 00:01:50 +0200, Oliver Kiddle wrote:
> One thing it also includes is the bash/ksh [[ -v ... ]] condition for
> checking if a particular variable is set. Zsh has the ${+varname} syntax
> which provides the same functionality in a different form. The following
> patch adds the ksh form for compatibility.
>
> The code for ${+...} is mixed in with the rest of the parameter
> substitution code so I couldn't easily reuse it. There may be subtle
> differences as a result. In particular it returns false for a string
> slice. That's arguably not a variable and would raise the question
> of string slices on an array slice.
>
> There's also subtle differences relative to bash/ksh. local/typeset
> in bash/ksh leave the variable undefined until it is given a value
> rather than making it an empty scalar. And bash doesn't seem to handle
> the positional parameters.
Shouldn't there be 3 states?
* not declared / not set
* declared but not set
* set
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author