zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Mikael Magnusson <mikachu@gmail.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: PATCH: <<<: Document newline behavior and fix optimization
Date: Wed, 9 Mar 2022 11:10:28 +0000	[thread overview]
Message-ID: <20220309111028.qng5toxrmzvsahqt@chazelas.org> (raw)
In-Reply-To: <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@brasslantern.com> 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


  reply	other threads:[~2022-03-09 11:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 18:58 Mikael Magnusson
2022-03-08 19:38 ` Bart Schaefer
2022-03-08 19:42   ` Bart Schaefer
2022-03-09 11:10     ` Stephane Chazelas [this message]
2022-03-13 18:50 ` Stephane Chazelas
2022-03-13 19:28   ` Mikael Magnusson
2022-03-13 19:35     ` Stephane Chazelas
2022-03-30  7:17 ` Jun T
2022-03-30  8:02   ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220309111028.qng5toxrmzvsahqt@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=mikachu@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).