Re: Zsh's and ksh's bang (!) expansion flags have different meanings
Bart Schaefer <[email protected]> Sun, 26 Jul 2026 22:03:39 -0700
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <CAH+w=7YA53htBHD2MSKGtxJqEWa+184ryiWm+rPDSmpBtWznZw@mail.gmail.com> |
--000000000000ebd0b3065790a524
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Thu, Jul 23, 2026 at 7:42=E2=80=AFAM Philippe Altherr <philippe.altherr@=
gmail.com>
wrote:
>
> I highlighted in orange the results where Zsh does something similar
> (return the index/key) but not in the exact same way as ksh (Zsh returns
> just the index/key, while ksh returns the full parameter spec).
>
The zsh behavior is what makes hash2=3D( "${(@kv)hash1}" ) work for copying
one hash to another.
Somewhat related, until relatively recently, zsh did not support the `var=
=3D(
[1]=3Dfirst [2]=3Dsecond )` assignment syntax.
As I've mentioned in the past, if you see ksh-like behavior in zsh that
doesn't quite match ksh, it's often because the ksh behavior was
implemented based on reading examples from the ksh manual pages way back
when ksh was proprietary software and unavailable for running a comparison.
Other times it's because the ksh behavior or syntax conflicted with
something else zsh was already doing.
--000000000000ebd0b3065790a524
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr">On Thu, Jul 23, 2026 at 7:42=E2=80=AFAM P=
hilippe Altherr <<a href=3D"mailto:[email protected]">philippe.=
[email protected]</a>> wrote:</div><div class=3D"gmail_quote gmail_quote=
_container"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0=
.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"l=
tr"><div dir=3D"ltr"><div><div><br></div><div>I highlighted in orange the r=
esults where Zsh does something similar (return the index/key) but not in t=
he exact same way as ksh (Zsh returns just the index/key, while ksh returns=
the full parameter spec).</div></div></div></div></blockquote><div><br></d=
iv><div><div>The zsh behavior is what makes hash2=3D( "${(@kv)hash1}&q=
uot; ) work for copying one hash to another.</div><div><br></div>Somewhat r=
elated, until relatively recently, zsh did not support the `var=3D( [1]=3Df=
irst [2]=3Dsecond )` assignment syntax.</div><div><br></div><div>As I'v=
e mentioned in the past, if you see ksh-like behavior in zsh that doesn'=
;t quite match ksh, it's often because the ksh behavior was implemented=
based on reading examples from the ksh manual pages way back when ksh was =
proprietary software and unavailable for running a comparison.</div><div><b=
r></div><div>Other times it's because the ksh behavior or syntax confli=
cted with something else zsh was already doing.</div></div></div>
--000000000000ebd0b3065790a524--