I thought the wildcard * in the command find . -name *foo* is replaced by bash, and yet the command works unless *foo* matches something in the current directory, then it doesn't. It's confusing.
How does `find . -name *foo*` work?
bash;find
If bash can't find a match, it passes the literal string to the application with *s unexpanded. For example:$ lsfoo$ cat /tmp/testecho $1$ /tmp/test *foo*foo$ /tmp/test *bar**bar*bash expanded *foo* because it matched, but passed *bar* directly because it didn't. The nullglob option will tell bash to resolve non-matching patterns to the empty string instead:$ shopt -s nullglob$ /tmp/test *bar*$