From ea99b9cf28ec94b17e2166158cf9cc779d319a57 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sun, 10 Nov 2013 12:01:17 -0800 Subject: [PATCH] Created Sc2035 (markdown) --- Sc2035.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Sc2035.md diff --git a/Sc2035.md b/Sc2035.md new file mode 100644 index 0000000..cb23717 --- /dev/null +++ b/Sc2035.md @@ -0,0 +1,15 @@ +# Use ./*.m3u so names with dashes won't become options. + +### Problematic code: + rm * + +### Correct code: + rm ./* + +### Rationale + +Since files and arguments are strings passed the same way, programs can't properly determine which is which, and rely on dashes to determine what's what. + +A file named `-f` (`touch -- -f`) will not be deleted by the problematic code. It will instead be interpreted as a command line option, and `rm` will even report success. + +Using `./*` will instead cause the glob to be expanded into `./-f`, which no program will treat as an option. \ No newline at end of file