Recently switched from bash, I noticed that zsh
will try to expand every command or argument that looks like it has wildcards in it. So the following lines won't work any more:
git diff master{,^^}
zsh: no matches found: master^^
scp remote:~/*.txt .
zsh: no matches found: remote:~/*.txt
The only way to make the above commands work is to quote the arguments, which is quite annoying.
Q: How do I configure zsh
to still try to expand wildcards, but if there are no matches, just pass on the argument as-is?
EDIT: Possibly related: scp with zsh : no matches found
Best Answer
It is an intended feature of zsh. when using any shell, it is considered best practice to quote any character that is considered a meta character to the shell.
^
is a pattern used to negate a string when the optionextendedglob
is set.*
is a pattern used to match zero or more characters.You can stop it by disabling the option
nomatch
. But by doing so, your unquoted patterns make your statements volatile, depending on what files may be present in the current working directory. You shouldn't do that.