0

Already in the 1980ies, ls -l did mostly what it does today. For a boolean option, in this case l, I hardly ever questioned why it is prefixed with a dash: without an indicator, ls l would mean "list file l", but a somewhat more logical indicator would have been a plus sign.

Extending to non boolean options or to explicitly specify false too, something like l=true or l=t could have happened too, as it actually did for the dd command.

I can guess why the dash (easy to write and implement), but:

Question: Does anyone have a historic rationale for using the dash for command line options, some pointer to an email or news exchange, some code comment, some old documentation?

7
  • 1
    I'd assume that this convention predates email and newsservers, and UNIX itself. Commented Jun 2 at 10:40
  • I would guess that it derived from Multics. See multicians.org/mgc.html#controlargument Commented Jun 2 at 11:56
  • 2
    It certainly goes back at least to the First Edition Unix (1971); see tuhs.org/cgi-bin/utree.pl?file=V1/man/man1/ls.1.  (Note that the use of -- in that page is an error; that page was created by scanning a hard copy and OCRing it.)  Economy of typing was probably a factor ��� an unshifted character/key like - would have been preferred over a shifted character/key like +. Commented Jun 2 at 12:34
  • @ChrisDavies Can you identify a date for Multics? There are dates in that Glossary document going back to the 1960s, but they seem pre-historic. Commented Jun 2 at 12:34
  • 1
    What's really hilarious is the way the plus sign is used in some contexts to disable a feature, mostly visible in the shells' set builtin, but it appears in command line options of some commands too. But I think G-Man has a point there about the hyphen/dash/minus being available without modifier keys in the US keyboard layout.
    – ilkkachu
    Commented Jun 2 at 14:35

1 Answer 1

2

Digging through historical articles in wikipedia, it appears that command line options were invented for the Multics shell and used a single dash to distinguish options from option values.

CTSS (Compatible Time-Sharing System) was the first attempt at a time sharing system (started 1959-1961) and the first shell like command line interface RUNCOM was added in 1963. Prior to CTSS, systems were batch driven, likely from paper tape or punch card. Several other time sharing systems were also created around 1963, but it appears their "command line" was integrated into the operating system rather than a separate shell and was closer to programming commands rather than what we would recognize as command lines.

When developers from CTSS moved on and started working on multics (1964-1969), the shell and command line as we know it was invented, including use of the single dash for options. These developers carried this over into unix in 1969 when they left the multics project.

Email apparently was invented around 1965 (again, for CTSS). Wikipedia claims a paper for RUNCOM was published 1965.

Knowing how the developers of unix like shortcuts and abbreviations, it is no surprise the would use - rather than + just because the latter is harder to type on the default US layout. Also consider that options were not necessarily binary flags, but option names paired with option values, both of which needed to be distinguished from regular parameters.

Other operating systems (vms, windows, after 1975) used / for options, likely just to be different from what they were copying.

2
  • 1
    VMS was/is a lot more verbose - both in terms of commands and the /option parameters. Maybe a consequence of the first UNIX system being written for a tiny PDP11 and therefore tight on memory and disk storage? Again, I'm only opining Commented Jun 2 at 13:55
  • @ChrisDavies you might have a point there; IIRC, CTSS and early MULTICS commands took arguments that where fixed 6 characters long (filled up with spaces); not too much room for verbosity. All this knowledge solidly predates me, all I've learnt was done going down rabbit holes after reading the (quite related) unix.stackexchange.com/questions/21852/… Commented Jun 2 at 13:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .