A question about the recommended usage of rm and --
Let's say I've created two files -i
and xx
. If I try to remove them with
$ rm *
I get:
rm: remove regular file `xx'? n
And, as explained in How do I remove a file in Linux whose name looks like it's ONLY a hyphen, as in "-" and others, the way of solving this is with:
$ rm -- *
Obviously the problems could possibly be much worse with names called -rf
or similar.
So my question is:
Should we systematically use
--
inrm
commands before anything that is expandable, to avoid unpleasant surprises or exploits?
The reason I ask this is that a while ago I learnt this rm
gotcha and then forgot it, until recently that a teammate brought it in again. However I have never seen any recommendations in that sense and being so risky, I wonder if we should have it more present? Should the usage of --
be some kind of scripting and console pattern whenever using rm
(and probably other commands)?