Monday 30 December 2019

shell - What is the origin of the UNIX $ (dollar) prompt?


The UNIX prompt uses a $ symbol to indicate that your input is expected.


I was wondering why this symbol was chosen—if there is a reason. Dollar just seems a little unexpected. A > symbol would have been more suggestive in my opinion.



Answer



Let's explore a little:




  • Version 8 Unix is easy. There's still man pages available. Get to the sh man page and search for prompt. You'll get to a point where you read:



    PS1 Primary prompt string, by default “$ ”.


    PS2 Secondary prompt string, by default “> ”.





  • So let's see if that was the first. Version 7 Unix man pages are still available, and the sh man page gives the same description of prompts as Version 8.




  • What about version 6? Version 6 Unix wasn't hard to track. But its sh man page doesn't mention prompts at all. The “Getting started” guide comes in handy here; it mentions:



    The culmination of your login efforts is a percent sign “%”. The percent sign means that UNIX is ready to accept commands from the terminal.





Aha! So version 6 didn't have it. Version 7 was the first! Released in 1979.


Happy? Hate to rain on your parade, but don't be :)


Problem is that version 6 was one inspiring Unix. Look at the variants here. Can it be that the $ sign as a command prompt was not started in Version 7, but instead in one of these variants and then the idea incorporated into 7?


At this point I got tired of hunting for operating systems documentation from a time when I was 6. This at least narrows it down considerably. We know Version 7 was the first Bell Labs release to show the $ sign as a command prompt. All we need to be sure is that none of those Version 6 variants introduced it. It makes sense for this change to have appeared in Version 7 though since that’s the release which introduced the Bourne shell, replacing the Thompson shell used in previous versions of Unix (and the Massey shell used in Programmer's Workbench Unix).


One last thought though:
While the idea of $ being a hint to the word shell or script is appealing and makes all sense, don't expect this to ever be officially confirmed. Unix development was shared by a rather large group of people with much bigger concerns in life than keeping track of how a symbol evolved. And some of these extraordinary programmers are not even among us anymore.


Most probably, the best you can hope to get from the question "What is the origin of the UNIX $ (dollar) prompt?" is the name of the first Unix shell introducing it.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...