Re: Zsh's and ksh's bang (!) expansion flags have different meanings

Stephane Chazelas <[email protected]> Tue, 21 Jul 2026 18:27:27 +0100
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
2026-07-21 16:27:08 +0200, Philippe Altherr:
> >
> > >>> In ksh, the (!) flag can be used to list the keys of arrays and
> > associative 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".
> 
> 
> Funny, I always assumed it was (k)ey (and (v)alue). Good thing that both
> ksh and key start with the same letter :-)
[...]

Me too and https://www.zsh.org/mla/workers/1998/msg00922.html
in design discussion for associative arrays would seem to
corroborate that.

Looking at git history, it seems those flags were added in
https://sourceforge.net/p/zsh/code/ci/d2330ba0554b09a3f942a921acfbbabcf6466bef/#diff-5
but not mentioned in changelog and apparently bundled with the
changes for https://www.zsh.org/mla/workers/2000/msg01372.html
by pws.

-- 
Stephane