Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Brace expansion in command position
- X-seq: zsh-workers 47599
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: Brace expansion in command position
- Date: Mon, 23 Nov 2020 04:05:56 +0000
- Archived-at: <https://zsh.org/workers/47599>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-11/20201123040556.GA31253%40tarpaulin.shahaf.local2>
- Authentication-results: zsh.org; iprev=pass (out3-smtp.messagingengine.com) smtp.remote-ip=66.111.4.27; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=fm1; bh=cnH CAOVWTUxoGaoKlZpLps1lV/0tHXMwnb21ReWDwOU=; b=rgjNAQAXfLGaXA+q5ux 0m1gKzjFM5mJiv7dTUyr6Up1qCOq8IIxlBVQObub8Cqn/UoQuPBCwPCIJlGZ6vCc PrpKiUld/3HVgb34kmhBAfCUax3NFS0+a+cdincKeRK/fJLfJuFWrG5St8NKGzj3 sIx3/vSO5J4nFK8ZF3uAKEKt0oAWOMMwW3qCc4v2WCrDUrhIihAvfC0v7UD6pIN6 UTKvuG4ZmFAhJp5f9dAfKelLO5NNpImN0vjE05DEtOJjDHn9UAd6j0WEjwnOzdKN xKVfjJF4/BQ8on3y8G+oIigEehJqTxLqqT7pycL1egRR+lSm3Xvm4E09/58mcH7h s8A==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=cnHCAO VWTUxoGaoKlZpLps1lV/0tHXMwnb21ReWDwOU=; b=hiXY9knYkdmS1i81z5Ph5S KHBBMmuQNXkWC3MJ/Jbh7NC6FN56+tRepTGZcnXh8jHcKS1hK7/DySs+8ZREzBDZ 9WTKmkM5EV9Y2CsqiiPcKFML/1z28SZYd8F+ulELxZdJe866lk80S49aDgNgIYzL mNq/8Ib3FpFL+AJ0f602FZzDo+D4ztAJoF8qo5mLR7J7z11eiqhQltfnmPwgY10A MlQGcg3rBnyQNTMX0e0KfS8pVtCe6I48nrbpWOVNQxoTZYfu1xn+aut+oLjseRQX Is62RpzELJFDsWKjxgYR3dSY65Fx8+EMHapyms7I1xVgMEHEXOapBjfbXTBzDgmg ==
- In-reply-to: <c2d275ebf2501b45b675c04f734582d502f7e325.camel@ntlworld.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <37c503f2-a4f5-4074-b33e-08505abaaaf7@www.fastmail.com> <c2d275ebf2501b45b675c04f734582d502f7e325.camel@ntlworld.com>
- Sender: zsh-workers-request@xxxxxxx
Peter Stephenson wrote on Sat, Nov 21, 2020 at 17:56:35 +0000:
> 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 :-).)
It's okay, there are plenty of fish in the sea ;-)
Seriously, thanks for the answer. This seems to be partially covered
by A02alias.ztst:"Aliasing reserved tokens", but I don't see any test
specifically about this, so:
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 35a04e7d5..c9a381812 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -939,3 +939,8 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci
$ZTST_testdir/../Src/zsh -fc '{ ( ) } always { echo foo }'
0:exec last command optimization inhibited for try/always
>foo
+
+ function 'ls,/' () {echo success}
+ {ls,/}
+0:current-shell blocks masquerading as brace expansion (test to ensure behaviour changes aren't unintentional)
+>success
Messages sorted by:
Reverse Date,
Date,
Thread,
Author