zsh has precommand modifiers, which precede a command to alter how command is interpreted. Some of them are command and exec.$ zsh -c 'exec -a foo zsh -c print -- \$0'foo$ zsh -c 'command -v ls'/bin/lsBut they stopped accepting arguments if quoted:$ zsh -c '\exec -a foo zsh -c print -- \$0'zsh:1: command not found: -a$ zsh -c '\command -v ls'zsh:1: command not found: -vSounds like quoted them making them run immediately without processing other arguments.It makes prevent alias named command or exec from expanding is impossible.Is this a bug or a feature? Is it documented somewhere?
Why zsh precommand modifiers stop accepting arguments if quoted?
zsh
Zsh parses precommand modifiers in the same way as aliases and keywords: they have to be at the beginning of a command, unquoted. This is pretty much necessary for modifiers that affect the parsing of the command (noglob, nocorrect). The precommand modifiers builtin, command, exec use the same logic internally even though they could be interpreted otherwise.As far as I can tell, there's no deep reason for this logic, just that it was done this way a couple of decades ago and nobody has cared enough about this edge case to fix it.Given that something like \command -v ls doesn't do anything sensible, it's definitely a bug.