zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Brace expansion in command position
Date: Sat, 21 Nov 2020 17:56:35 +0000	[thread overview]
Message-ID: <c2d275ebf2501b45b675c04f734582d502f7e325.camel@ntlworld.com> (raw)
In-Reply-To: <37c503f2-a4f5-4074-b33e-08505abaaaf7@www.fastmail.com>

On Sat, 2020-11-21 at 15:31 +0000, Daniel Shahaf wrote:
> [[[
> % type pwd
> pwd is a shell builtin
> % {pwd,-P}
> zsh: command not found: pwd,-P
> % builtin {pwd,-P}
> /home/daniel
> ]]]
> 
> I expected the second command to do what the third command does.

"{" in command position introduces a list to be run in the current
shell, not a brace expansion.  So this is treated as { ... } where the
... here is the single-word command "pwd,-P" as a comma has no special
meaning at this point.

Actually, other shells require a space after the "{", as well as a
command terminator ";" or newline before the "}", but zsh doesn't.
Other shells don't need a space or terminator in the subshell form,
with parentheses (...), so this is another of those minefields it's
quite hard to pronounce definitely on.  (This may not stop other people
trying, excuse me if I don't take the bait :-).)

pws



  reply	other threads:[~2020-11-21 17:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-21 15:31 Daniel Shahaf
2020-11-21 17:56 ` Peter Stephenson [this message]
2020-11-23  4:05   ` Daniel Shahaf

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=c2d275ebf2501b45b675c04f734582d502f7e325.camel@ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).