Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: What is the '+' option of the 'typeset' builtin supposed to do?
- X-seq: zsh-workers 55153
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: What is the '+' option of the 'typeset' builtin supposed to do?
- Date: Sun, 13 Sep 2026 14:22:24 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=WSSGjeiOurN24gtAnPNHjIBuGCTLLSsQ2B9lSNJbd+k=; fh=BgAYDYpL6Ne/A5nWEMVJiHiBtrz8Imz3uf26RDwgQX4=; b=Z4011dyWANdzdoZnIyDvieCho42tnfb6D0lb+kdUsZy8lGervulZJ9qlGp72vSCG/+ 5zkRLHSzSjxFuB1SJV9aO+vP1aQ1IQi+JIMksYA7Kb+NvTmHxJOEnn6eumoTiG29BI5S ez63LD2CMcEP+WSDao/QgB6OlGzRqxAu8c/U83coMOakKxTPck6/rMmqFFG5Ja/hc31w p6gvVOVowFtYNRp4K39IdrxccHjFJoBqTqQ7QZtyxUresS1gaKspKAnbhriMuwjAJs0X aVIqntjqfEEcamfVvrQNzC6HL0zyv9IH8Kga4FXKqEUBsPD0rBcwsCtYbSytaS34DFlo Bv1g==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1789334557; cv=none; d=google.com; s=arc-20260327; b=KWS+7vVx6n7MpsjEbKyFn9DElVyT4ldtOL21CIFv6LTK0kb4TKZ6uHx5LgKVR7ghEs wSDJ9wMYv9szvoJGbqsuJS0+G6yhiscHOPDBOdQHPnM+pq9FtqMPjXCZZ2YqU7e8Enrt UhEu8t6xcMzZWJ18piv8Ju5AWfqbTbaYlYgi5SMzf0AYKap6qQPNQthZ5VI4kzok3Vkt 3ZlBBmFWIqTpZ8Mg+ltYEQkn+ESko8aKQkzxSQLW0bUhgxXPQVsTB8SMEhWogAx+bLf9 Ylf9O9eOvvqj6rjm36x6eFUhGj7udRer1zVZ3BJM1ZT7Vt4CFj0iahwVe+AyxyiOKCAR 3hVQ==
- Archived-at: <https://zsh.org/workers/55153>
- In-reply-to: <CAGdYchuGX6i8qWbnbvBZrvGif6qATn1rxvLoUM_13b5JywmMww@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchuGX6i8qWbnbvBZrvGif6qATn1rxvLoUM_13b5JywmMww@mail.gmail.com>
On Sun, Sep 13, 2026 at 8:55 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> If ‘+’ appears by itself in a separate word as the last option
This is something inherited / extended from ksh, so in part this
should follow the implementation there.
The most significant bit is this:
> 'typeset + str=abc int=1+2' prints nothing and assigns the parameters => ???
That's what ksh does. Assignments always "win". Worth documenting.
> ... the effect of ‘+’ is as if all attribute flags which precede it were given with a ‘+’ prefix. For example, ‘typeset -U +’ is equivalent to ‘typeset +U’ ...
This is dependent on an earlier bit of doc:
If no NAME is present, the names and values of all parameters are
printed. In this case the attribute flags restrict the display to
only those parameters that have the specified attributes, and using
'+' rather than '-' to introduce the flag suppresses printing of
the values of parameters when there is no parameter name.
So `typeset -U +' and `typeset -U + foo' are distinct and the latter
is not the same as `typeset +U foo' despite what's implied by
combining the standalone-'+' paragraph with only the "rather than"
clause of the '+flag' paragraph.
Further, `typeset +U + foo' ignores the standalone '+' entirely and
removes the uniqueness attribute from foo, which is not documented
clearly at all and probably represents an unintentional edge case that
also explains your question about `-i +'.
> 'typeset +' prints the name and type of all parameters => ok
Ksh prints only the names of all parameters, so this is an extension.
> 'typeset -i +' prints the name of all integer parameters => ok
This mirrors ksh exactly.
> 'typeset -t +' prints the name of all tagged parameters => ok
Presumably correct.
> 'typeset -i -t +' prints the name of all integer parameters => okish
> Why not print only tagged integer parameters?
This probably comes down to an oversight in how printparamnode() is
implemented. Tagging has always been a bit of a non-feature feature.
> 'typeset + str int' prints the name and value of the listed parameters => ok
> 'typeset -i + str int' prints nothing but turns the listed parameters into integers => KO
> Why does that change the type of the parameters?
See above. I've no strong feelings about whether this should be
changed or merely properly documented. Anyone?
> Shouldn't this just print the name and value of either all the listed parameters or of just the ones that are integers?
If it IS changed, I would say "just the ones that are integers" ...
although that conflicts with the behavior of `typeset -i -p NAME...',
so uncertain.
> 'typeset + undef' prints nothing and creates a string parameter => KO
> Why does this create a parameter?
This probably an accidental effect of the "assignments always win" behavior.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author