Globs getting interpreted as switches is a very unfortunate footgun, sure, but I don’t see how you could eliminate it while retaining the same level of smarts in the shell (tokenization but only into dumb strings), and DOS/Windows command line parsing is IMO essentially a reductio ad absurdum for the idea of having less (no tokenization, but the shell still splits commands). Except maybe require the -- between switches and arguments whenever there are arguments? But not only is that an incomplete fix, it also goes contrary to convenience of interactive usage, which is important: much of the tension in shell syntax and Unix utilities is due to balancing it with conventional programming, I feel, and I wouldn’t want to be writing even Perl or Tcl instead, let alone Powershell or the like.
https://www.defensecode.com/public/DefenseCode_Unix_WildCard...
echo a > -
echo b | cat -- -
Output: b $ touch -- -rf
$ mkdir subdir1
$ touch subdir1/test1
$ rm *
$ ls
-rf
$
With zsh it's almost the same, it just warns me first: $ touch -- -rf
$ mkdir subdir1
$ touch subdir1/test1
$ rm *
zsh: sure you want to delete all 2 files in /path/to/test [yn]? y
$ ls
-rf
$
Since there was a file called -rf, `rm *` expands to `rm -rf subdir1`, and that's what it does. The actual file named -rf survives because -rf was interpreted as an option rather than a filename. It would only have been removed if I did `rm -rf -- *`.