Re: Zsh's and ksh's bang (!) expansion flags have different meanings
Mikael Magnusson <[email protected]> Mon, 20 Jul 2026 02:34:45 +0200
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <CAHYJk3Tk_p=XKej2X=oBcXa52hfsrc5WLQbUf7hF-pkGkyFiwQ@mail.gmail.com> |
On Sun, Jul 19, 2026 at 11:53=E2=80=AFPM Bart Schaefer <[email protected]> wrote: > > On Sun, Jul 19, 2026 at 10:24=E2=80=AFAM Philippe Altherr > <[email protected]> wrote: > > > > On Sun, Jul 19, 2026 at 6:36=E2=80=AFPM Bart Schaefer <schaefer@brassla= ntern.com> wrote: > >> > >> You're not noticing anything new, or rather the only thing new that yo= u're noticing is that the (!) flag exists at all. > > > > I'm fully aware that the (!) flag is a part of named references, so not= already present in any released version of Zsh. > > Well, yes. The (sorry, unstated) point was that everything you said > about (k) is long-standing and (hopefully?) derivable from > documentation or FAQ. > > However, if someone wants to convert those tables of differences into > a format that could be included in either the FAQ or the "Other > Differences" section of the zsh/ksh93 module documentation, it would > probably be quite useful. > > >>> In ksh, the (!) flag can be used to list the keys of arrays and assoc= iative arrays. In that regard, it's closer to Zsh's (k) flag than Zsh's (!)= flag > > The (k) flag was originally intended to mimic ksh's ! name prefix (due > to ! colliding with history). The character "k" was chosen as a > mnemonic for "like (k)sh". I suppose, rather than introduce (!), I > could have extended (k) for the named reference behavior, to preserve > that similarity. Could still try that if it seems a good idea. I guess this would conflict with nameref-to-assoc, which currently does what I would expect. (Unless I'm missing something). % typeset -A a=3D( a 1 b 2 ) % typeset -n n=3Da % echo ${n} 1 2 % echo ${(k)n} a b --=20 Mikael Magnusson