If a glob pattern doesn't match any files, bash
will just return the literal pattern:
bash-4.1# echo nonexistent-file-*
nonexistent-file-*
bash-4.1#
You can modify the default behavior by setting the nullglob
shell option so if nothing matches, you get a null string:
bash-4.1# shopt -s nullglob
bash-4.1# echo nonexistent-file-*
bash-4.1#
So is there an equivalent option in ash
?
bash-4.1# ash
~ # echo nonexistent-file-*
nonexistent-file-*
~ # shopt -s nullglob
ash: shopt: not found
~ #
For shells without
nullglob
such as ash and dash:Source: Filenames and Pathnames in Shell: How to do it correctly (cached)