Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: <<<: Document newline behavior and fix optimization
- X-seq: zsh-workers 49817
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Mikael Magnusson <mikachu@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: <<<: Document newline behavior and fix optimization
- Date: Wed, 9 Mar 2022 11:10:28 +0000
- Archived-at: <https://zsh.org/workers/49817>
- In-reply-to: <CAH+w=7Zzu8P81JXh88CAS5QNz359ryDNqnih7fxdMAMeNpDHGQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Mikael Magnusson <mikachu@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <20220308185832.27204-1-mikachu@gmail.com> <CAH+w=7ZLMyWpvjCgFem+VmkVPqWVKaW6nKUkaDBSjepURnRNbA@mail.gmail.com> <CAH+w=7Zzu8P81JXh88CAS5QNz359ryDNqnih7fxdMAMeNpDHGQ@mail.gmail.com>
2022-03-08 11:42:31 -0800, Bart Schaefer:
> On Tue, Mar 8, 2022 at 11:38 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > I regularly make use of the fact that <<<foo does not add a newline
>
> Or, hmm, I thought I did, but that can't be. What am I thinking of?
In Byron Rakitzis's clone of rc, <<< does not add a newline. I
heard here that that's the shell that introduced <<<, though
I've not found evidence of the fact that rc had it before zsh.
Maybe you were thinking of "$(<<<foo)" which strips trailing
newline*S* just like "$(echo foo)". The fact that it strips more
than one newline is a misfeature IMO though (shared by all
Bourne-like shells). That makes it that things like
dir=$(dirname -- "$file")
Are incorrect as they fail for files whose dirname ends in
newline characters (and why you want to use dir=$file:h instead
if you're lucky enough to use zsh).
I was thinking at some point maybe we could add a
$CMDSUB_RTRIM special variable, which one could set to $'\n' (or
$'(\r|)\n' for MSDOS users) instead of the default of $'\n#'
to allow users to fix that problem.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author