Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Brace expansion in command position



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





Messages sorted by: Reverse Date, Date, Thread, Author