Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Nofork and preserving newlines
- X-seq: zsh-workers 52624
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Nofork and preserving newlines
- Date: Tue, 27 Feb 2024 12:53:20 -0800
- Archived-at: <https://zsh.org/workers/52624>
- List-id: <zsh-workers.zsh.org>
On Tue, Feb 27, 2024 at 11:25 AM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> Incidentially, trying to use kill -l in that
> manner, it becomes apparent why the `...` and $(...) forms strip
> trailing newlines. Given that it aids compatibility with bash/ksh etc
> and updating old zsh scripts that use $(...) I'm not too sure that it
> preserving newlines is the most helpful behaviour. Parameter flags don't
> appear to work with the new form so adding one of those isn't an option.
You can do ${=${ ... }} or ${(f)${ ... }} but, correct, not e.g. ${(f)
... }. Consensus during the discussion seemed to be that the extra
layer of braces was not onerous when needed.
The intent was to have ${ ... } act more like parameter substitution.
It might be possible/reasonable to have ${ ... } strip newlines and
"${ ... }" keep them, if that feels better.
I suspect there are not very many old scripts that use purely builtin
commands in $(...), and as noted elsewhere there's really no reason
(other than no newline stripping!) to use ${ ... } for external
commands because zsh optimizes out one fork in $(...) already.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author