How to match nothing if a file name glob has no matches [duplicate]
This and a duplicate question both were in context of not just pathname-expansion, but also brace-expansion, and a duplicate asked for POSIX.
The compgen -G
does bash --posix
compatible pathname-expansion (no brace-expansion) and... you guessed it: yields nothing if there are no matches.
Therefore write a bash --posix
function to do it. Brief outline: temporarily use set -f
to first do brace-expansion (without pathname-expansion) via an echo, then apply compgen -G
to each result for pathname-expansion. Full function left as an exercise.