Another common footgun is not including a double dash ('--') at the end of command options so that the following filename won't be interpreted as an option when it begins with a dash.
Another common footgun is not including a double dash ('--') at the end of command options so that the following filename won't be interpreted as an option when it begins with a dash.
Yes. And if you have a file name that begins with a dash, and you want to delete it, you can use this command:
$ rm -- -filename
where -filename is that file. Here, the -- (double dash) means "end of the command-line options", so any argument after that is treated as a non-option argument, in this case, a filename for rm to delete.
This -- (double dash) works with many Unix commands. It was introduced relatively early on in Unix history, after the issue of filenames starting with a dash was found.
Although it is more likely that you would want to rename the file, to remove the dash from the name.
There are places in Makefiles where no amount of quoting will help you, and it simply cannot handle files with spaces.
Yeah, this is a problem with the tool that should be fixed, but my understanding is that it will never be fixed because of architectural reasons. And it's a very popular, useful, and most importantly, ubiquitous tool.
So this is another good reason to simply have a policy of banning filenames with spaces (and there are many more reasons).