From: Bart Schaefer <schaefer@brasslantern.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Use glob patterns while reading a file
Date: Fri, 9 Nov 2018 18:07:43 -0800 [thread overview]
Message-ID: <CAH+w=7YuTY2W6R=tOrD+DijiiboQxJ-EDRROxhB05+gwwQEgRg@mail.gmail.com> (raw)
In-Reply-To: <1541812878.2985396.1571973512.684C1909@webmail.messagingengine.com>
On Fri, Nov 9, 2018 at 5:22 PM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> > > $(< ./(a|b)(N))
> >
> > That's a special syntax, expecting a single file so that it doesn't try
> > to do globbing.
>
> I think this violates the principle of least surprise. Grammars should be
> composable and shouldn't have special cases.
Although I can't argue with this from a philosophical standpoint, I
find it astonishing to pretend that zsh ignores that philosophy only
in this particular case.
> The forms «foo» and
> «print -r -- "$(<foo)"» should always be equivalent (assuming 'foo' outputs
> a trailing newline).
I don't follow that at all. «foo» is a shell word. «print -r --
"$(<foo)"» is the contents of a file identified by the word «foo». In
what context are those equivalent?
> Similarly, «<foo» and «<foo $READNULLCMD» are usually
> equivalent, but «$(<*)» and «$(<* $READNULLCMD)» are not.
The distinction here is that $(...) is a substitution, not a subshell.
It's more like a quoting mechanism (i.e. `foo`). $(<foo) is NOT an
"optimization" of $({<foo}) (which does work exactly the way you think
it would, globbing-wise), and the "<" in that position in the
substitution is not a redirection operator, even though it looks like
one for mnemonic reasons. $(<...) is an entirely different thing,
just like $((...)) is a different thing, even though «$(» and «<» do
not have to be composed without whitespace to form a token.
> was this behaviour intentionally implemented this way?
Yes.
next prev parent reply other threads:[~2018-11-10 2:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20181108225555epcas2p274de218aef35e46f189ebbfbd9d1892f@epcas2p2.samsung.com>
2018-11-08 22:53 ` Dominik Ritter
2018-11-09 9:35 ` Peter Stephenson
2018-11-09 14:37 ` Dominik Ritter
2018-11-09 16:20 ` Peter Stephenson
2018-11-10 1:21 ` Daniel Shahaf
2018-11-10 2:07 ` Bart Schaefer [this message]
2018-11-10 2:12 ` Bart Schaefer
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='CAH+w=7YuTY2W6R=tOrD+DijiiboQxJ-EDRROxhB05+gwwQEgRg@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=d.s@daniel.shahaf.name \
--cc=zsh-users@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).