Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH?] Nofork and removing newlines
- X-seq: zsh-workers 52760
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Oliver Kiddle <opk@xxxxxxx>
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: [PATCH?] Nofork and removing newlines
- Date: Fri, 15 Mar 2024 08:42:26 +0000
- Archived-at: <https://zsh.org/workers/52760>
- In-reply-to: <31438-1710454547.652877@WxhA.vkY6.ljF0>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Oliver Kiddle <opk@xxxxxxx>, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- References: <c053e1e2-b9e1-44af-aae4-4998e768e7ed@app.fastmail.com> <CAH+w=7b24HxJMGUBqjC7Fgx3ycLWwAuK0CTpwSSryb0XXxEHMw@mail.gmail.com> <90726-1709936102.086878@xlWC.oGpX.V4Q4> <CAH+w=7Zv1RsPoFBsLVjqS5wh0n4wQpsVQg3z2pKpfuYkjRk6CA@mail.gmail.com> <34739-1710017038.959920@XhYc.enDL.DTxr> <CAH+w=7Zk2usqyP1CtviobNZNnzAxhh_f5tnPdj-aLkBjX6B_cw@mail.gmail.com> <CAH+w=7Zb_PWs-h2J9uOUMT6TQXnfPUAXyCWZUEcKyyDx0fDLhg@mail.gmail.com> <25344-1710285573.990297@5-7t._0Mp.XRXG> <CAH+w=7aFbL8c=RLcrkKJU4R-o2ZhNJgS+zi60STswpFbE4BWqg@mail.gmail.com> <31438-1710454547.652877@WxhA.vkY6.ljF0>
I don't know if that could be done and it's probably too late
anyway, but I thought I might throw in the idea anyway.
What about, instead of adding ksh93's ${ cmd;} and mksh's
${|cmd} (in slightly diverging ways), we added just a |
expansion flag whereby:
${(||)any zsh code} would expand to the output of the code
without the fork and without the newline trimming.
${(|var|)any zsh code} would expand to the value of var as set
by the zsh code
Some advantages:
- the flags can be cumulated as usual. So you can have ${(||.s[:])getconf PATH}
to split the output of getconf PATH ("." to trim one newline,
".." to trim all) for example.
- there's no extra rule as to how the expansion works and how it
can be combined with others as it's the same syntax as other
parameter expansions
- as it's different syntax, it removes the potential surprises
when ${ cmd;}, ${|cmd} behave differently than in
ksh93/mksh/bash
=============
Or (as a completely different idea), an alternative to
mksh's ${|cmd} and ${|var|cmd} could be written ${REPLY<cmd}
${var<cmd}.
That could be added as well as ${|cmd} if we wanted to add
${|cmd} for compatibility with mksh/bash.
Or we could add neither of ${ cmd;} and ${|cmd} and have
${REPLY<cmd} as the (non-splitting, non-trimming) equivalent of
${|cmd} and ${<cmd} as the (non-splitting, non-trimming)
equivalent of ${ cmd;} (though the latter would prevent adding
${ cmd; } in the future).
And still allow flags there as in ${(.s[:])<getconf PATH}
--
Stephane
-
Messages sorted by:
Reverse Date,
Date,
Thread,
Author