From: Daniel Shahaf <d.s@daniel.shahaf.name> To: Peter Stephenson <p.w.stephenson@ntlworld.com> Cc: zsh-workers@zsh.org Subject: Re: Brace expansion in command position Date: Mon, 23 Nov 2020 04:05:56 +0000 Message-ID: <20201123040556.GA31253@tarpaulin.shahaf.local2> (raw) In-Reply-To: <c2d275ebf2501b45b675c04f734582d502f7e325.camel@ntlworld.com> 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
prev parent reply other threads:[~2020-11-23 4:06 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 2020-11-23 4:05 ` Daniel Shahaf [this message]
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=20201123040556.GA31253@tarpaulin.shahaf.local2 \ --to=d.s@daniel.shahaf.name \ --cc=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
zsh-workers 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 \ zsh-workers@zsh.org public-inbox-index zsh-workers Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.vuxu.org/vuxu.archive.zsh.workers code repositories for the project(s) associated with this inbox: https://git.vuxu.org/mirror/zsh/ AGPL code for this site: git clone https://public-inbox.org/public-inbox.git