Per a discussion in Chat, when was command line parsing (using positional parameters) first introduced to the Unix shell?

And also, was the naming of $1, $2 etc. in any way borrowed from C (for example, from the indexing into C's argv[] array)? Or did that too, like many other things in the shell syntax, come from Algol 68?


When the first shell was created in 1971. The man page says:

When the shell is invoked as a command, it has additional string processing capabilities. Recall that the form in which the shell is invoked is

sh [ name [ arg1 ... [ arg9 ] ] ]

The name is the name of a file which will be read and interpreted. If not given, this subinstance of the shell will continue to read the standard input file. In the file, character sequences of the form "$n", where n is a digit 0, ..., 9, are replaced by the nth argument to the invocation of the shell (arg ). "$0" is replaced by name.

  • That rules out a C ancestry then.
    – Kusalananda
    May 16 '18 at 18:27
  • And likely rules out an Algol 68 ancestry as well, because Bourne didn't come to Bell Labs until 1975. May 16 '18 at 19:19
  • You may be mistaking Bourne for Thompson, in any event. (-:
    – JdeBP
    May 17 '18 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.