To elaborate this: the issue is similar to the link you posted. The problem is with the * expansion by the shell.
1) You use "*.dir"
: then literally this will be searched for, i.e. a directory name starting with a "
and ending with a "
2) You use *.dir
: then it will be expanded by the shell already at the assignment of command
What also works, is to avoid the expansion of the asterisk by the shell:
set -o noglob on
is worse for any other command depends what you want to achieve.
Ok, crts was faster - another solution.