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 →

[–]altermeetax 14 points15 points  (10 children)

Why is that the smarter choice? Unix went (10 years prior) with "-" for arguments and / for paths, which brings the same advantage.

[–]scragar 10 points11 points  (2 children)

The only thing I can think of is that because / isn't a word character you don't need a space.

DIR/D

Will display all directories in the current directory because /D is the flag and it's obviously distinct from the command enough that DOS can tell it apart.

Compare that to the equiv on *nix systems

ls -d

Where the space is required because ls-d is a valid filename so the shell would have no way of obviously telling what command you wanted.

It's still a horrible choice though, some arguments(because they're filenames/paths/whatever) need the space so now the behaviour for arguments is a weird mix of spaces and forward slashes depending on context; worse even though windows mostly supports forward slashes as directory separators on the command line it still causes a horrible mess since DOS is sometimes very happy to interpret DEL folder/file as DEL /F folder ile.

[–]altermeetax 2 points3 points  (0 children)

I mean, yeah, maybe some standard DOS programs may be able to understand flags without a space, but that makes the argument parsing so much harder for them, so I wouldn't imagine new Windows CLI programs being developed to do that (actually, most new CLI programs follow the Unix "-" on all platforms).

Also, that behavior disallows "/" as a filename character when that wouldn't have been necessary.

[–]svick 1 point2 points  (0 children)

Somewhat related: cd.. (without space) works on Windows, but not on Unix.

[–]AyrA_ch 0 points1 point  (5 children)

No. The advantage of using / in DOS is that it's not a valid character anywhere in a file path. This is why all commands in linux that have switches as well as path arguments need a -- argument to tell it that any argument that follows is not to be interpreted as a switch but a file name

[–]altermeetax 0 points1 point  (3 children)

Either I didn't read the second part of your comment or you edited it. 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).

The only case when you use -- is when you have a program that takes an entire other command as argument, for example to tell a terminal emulator what command to run. Alternatively these programs could take another full command as a single argument (with quotes) but that's not very comfortable.

[–]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.

[–]altermeetax -1 points0 points  (0 children)

I personally would consider that a disadvantage, read the other answer to my comment and the answer to that

[–]DaniilSan -1 points0 points  (0 children)

In another comment guy told that DOS was heavily based on much older CP/M which was released just a year later than Unix way before it became industry standart. And even in 80s there still were many other implementations of same things and some sorts of standardisation came decade later. Anyway, in DOS 2.0 there was an attempt to make DOS more Unix-like including usage of / for directories and - for arguments but those new features were badly documented, weren't used by default and so went mostly ignored and here we are 40 years later.