help / color / mirror / 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
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 :-).)


  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:

* 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 \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link


This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:

code repositories for the project(s) associated with this inbox:


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git