Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Zsh's and ksh's bang (!) expansion flags have different meanings
- X-seq: zsh-workers 55001
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Philippe Altherr <philippe.altherr@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Zsh's and ksh's bang (!) expansion flags have different meanings
- Date: Mon, 20 Jul 2026 02:34:45 +0200
- 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:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=QWAeObmik/EQ6Dr3Mc3ye2/+gN1Hpw/RvMcmwWv5fiA=; fh=mmfcfUEpoGXXpN6oQOWyeihnFMtjN/zRq2I9a87/LeM=; b=c9irWfMxNnHTd8p7BLzyQFaiCLUejQbAXMIPwRn95G3S2dE5KV75yg8c3bnTzltPIg UhGRU1EGbaCXFx6vTrkIJKodZigqkAEaU0AJ7AENTsL5/OGRdj1ULJ+pPuAa1Ye2I2YX Duxk62gdEdw/qe/zdFjLuu+Dz47KlGwGOMQ52OrAZaKJWIRRB9p0QsIf+VDZxin5nnph 7p3JGDr40xs2AhMxQwEQOm6Zp2utnYc824TkncedYkU1c1Hf5wt39Eq/iPGq0gKJjEaE BhvzYvKcot1YU88r3WP+o6xoBW7pdJV2tzEJ/cuGN85t/VcYKDD6M78kM7f8Zc6YXqQ0 H2qg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1784507699; cv=none; d=google.com; s=arc-20260327; b=pYLbMcj0rnpLYu6g9J3NAWEEK/aXc5w3FgwF8JRfelcyz4UxUxXlzFHJgqreYU+BLr GRC1OTFs3DRz56PvW6u3pi+kB/3D/NpcPSmfRPlXQt2GagcWBR+YaBUoXwp13olTCQuQ zlMIQxfEnIi1pgjDvAqZKfBw3rpWRMIfBjxSQDinFlT8QUxLzdqxUgqlHs5ThUs/Xw3I 1ByCw2I9ddFiwlI+dWBKahqzYva/+Cff9uJoNvLF9aqJcCu6cseT8RSruUYrMnnvWC6o oivKMJf99/rIpcDKZBlFRY+XWm8vdqck5bdcxAHgFK2ij6Hos/TgfIddC5HOLCPtweTk bc1g==
- Archived-at: <https://zsh.org/workers/55001>
- In-reply-to: <CAH+w=7aq63XvQkXi3-JDHi+F91Xj_ei7Dpg9jT65jaoj5ZkOPw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchvRE_B4b0yuk9drdR3dKb-2ci5r9PC5mUsVQ=x8tm2-1g@mail.gmail.com> <CAH+w=7Zd1Ov6XHYom1Ybs5oSujPyUTzX4213dMP968L53O7WEw@mail.gmail.com> <CAGdYchsKwb=Rpx9Rgv0yACZvjbFHSFjq-QmLY701UeCY9=PRzA@mail.gmail.com> <CAH+w=7aq63XvQkXi3-JDHi+F91Xj_ei7Dpg9jT65jaoj5ZkOPw@mail.gmail.com>
On Sun, Jul 19, 2026 at 11:53 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Sun, Jul 19, 2026 at 10:24 AM Philippe Altherr
> <philippe.altherr@xxxxxxxxx> wrote:
> >
> > On Sun, Jul 19, 2026 at 6:36 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >>
> >> You're not noticing anything new, or rather the only thing new that you'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 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". 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=( a 1 b 2 )
% typeset -n n=a
% echo ${n}
1 2
% echo ${(k)n}
a b
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author