Search code examples
zshglob

zsh make **/*.cpp **/*.cxx **/*.hpp not result in error


I have "v" aliased to "vim **/*.cpp **/*.hpp **/*.cxx"

Problem is, if I'm in a directory without any *.cxx files, zsh treats this as an error. Is there anyway to tell zsh to create the absence of **/*.cxx files as "" instead of an error?


Solution

  • It sounds like you want:

    set -o NULL_GLOB
    

    Another variation that may be of interest is:

    set -o CSH_NULL_GLOB
    

    They work slightly different when all the patterns fail to expand. When at least one pattern successfully expands, the two are the same. But if none of the patterns expand, NULL_GLOB will still run the command while CSH_NULL_GLOB will return an error.