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

Re: More rabbit-holes with unset variables



On Thu, Nov 26, 2020 at 5:21 AM Oliver Kiddle <opk@xxxxxxx> wrote:

> It appears that export VAR will not export an empty VAR even in zsh
> (unless you do VAR=""). So zsh's not exactly consistent.
> typeset [-x] is arguably just a variant of export.

That is a good point. Why does zsh return nil in this case?

  typeset -x FOO
  sh -c 'echo ${FOO-nil}'

> Felipe Contreras wrote:
> > The discussion is about what "typeset var" (with no type) should do.
>
> That is not "with no type", it has the default type which effectively is
> a string. Other shells also treat such variables as an empty string for
> the purposes of other features. Try += for example.

I mean the user specified no type.

What each shell implementation decides to do with that depends, but
the user specified no type. Yes, it makes sense to use string as the
default type, but some weird shell implementation might decide not to.

Cheers.

-- 
Felipe Contreras




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