Hacker News new | ask | show | jobs
by voyou 3821 days ago
Except that Unix also allows "-" in the filename, and as far as I know always has done. Using "--" to mark that all subsequent arguments should be treated as filenames rather than options has worked fine to allow Unix programs to access files beginning with a dash (including files called "--").

The actual reason that DOS uses "/" to mark options isn't technical, it's purely historic: that was the character that CP/M used.

2 comments

And UNIX allowing - in filenames is a massive security problem[0]. If you go grab a bunch of random scripts off of GitHub many of them won't correctly escape filenames, and a specially named file can alter how the script executes.

[0] http://www.net-security.org/article.php?id=2061

The security problem is incompetent programmers, not dashes, then.
Users and programmers. It is trivial to mistakenly execute a command on the shell which is subject to this issue.

I'd call the behaviour "dangerous by default." You need specific training to be aware of, and overcome the issue, without the training you're likely executing commands which can be taken advantage of (in particular recursive commands over files and directories you yourself don't control).

It's technical in the sense that the historical decision was already made at the OS layer and subsequent DOS/Win programmers have to work with it in the app layer.

Yes, 40 years ago, the decision was arbitrary not technical.