Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with unset variables
On Wed, Nov 11, 2020 at 11:02 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
>
> > 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.)
OK. But why isn't zsh doing this by default?
--
Felipe Contreras
Messages sorted by:
Reverse Date,
Date,
Thread,
Author