Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with unset variables
> On 11 November 2020 at 16:56 Felipe Contreras <felipe.contreras@xxxxxxxxx> wrote:
> If I actually do something on the foo() function:
>
> typeset var
> [[ -n "$1" ]] && var=$1
> echo "var: '${var-other}'"
>
> I would expect two things: 1) var is not set when I exit the function,
> and 2) var is not set until I specifically set it.
If you want the variable to be regarded as both local in scope and
unset, you can
typeset var
unset var
and the scope stays local, so this is safe.
(I thought we already did something like this in emulation but I may
not be remembering correctly.)
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author