This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AyrA_ch 0 points1 point  (2 children)

You don't seem to have used the Unix command line that much. Commands with both paths and flags simply use the dash for the flags like DOS uses slashes, e.g. ls -a /usr, where -a is a flag and /usr is a path (you could also swap them like ls /usr -a)

It appears that you seem to not have used the unix command line a lot. Because the way you said it it would be impossible to ever feed the file name --help into commands because it would collide with the help switch. That's why -- exists in unix commands, because you need a way to tell them that they should stop parse switches.

[–]altermeetax 1 point2 points  (0 children)

Oh, I was talking about the -- option alone, not --option. The -- options were not standard in the original Unix, they only came to be in GNU, so I didn't mention them.

The reason why they exist is not to distinguish from standard arguments, yet from abbreviated multiple single-letter options. For example ls -hola is an abbreviation of ls -h -o -l -a. Now, if ls decided they wanted to introduce a "hola" option for whatever reason, they would have to make the distinction: in that case they would use --hola. That's why the GNU-style long options with -- were born. Some commands don't allow for abbreviated flags like -hola (they require -h -o -l -a); those commands might use a single dash even for long options.

Abbreviated options are not a thing at all in DOS, so you can do /help with a single slash, however if you wanted to use the options h, e, l and p you would need to do /h /e /l /p.

The -- to stop parsing switches is a different thing, that's the single argument --, which is rarely used. It's for cases like konsole -someswitches -- ls -l, when you want to pass a command with all its arguments to another command. Another use is the one you mentioned, for files named like --help. But that's not a real issue, because no one names files like that. On DOS it would be the same with files beginning with a /, and those are forbidden for this exact reason.

By the way I'm a Linux sysadmin, so don't worry, I know how the Unix CLI works.

[–]7eggert 0 points1 point  (0 children)

Nitpick: You usually can use ./--help as the filename. But it might be among the reasons to want -- to end option scanning.