Re:Unix Wildcards Gone Wild (2014)
by Pete_D on Friday June 22, 2018 @05:16PM
(#17377439)
I didn't see this mentioned in the article, but you can protect against this in your own scripts by including a -- before user-supplied parameters, which prevents them from being treated as flags.
(see Guideline 10, http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_...)
[ Parent
| on HN ]
It should be noted that you will run plenty of programs in the wild that don't respect this convention.
Alternatively:
$ rm ./-rf