9

What is the etymology of $PWD? Is it an acronym?

I know there is a command pwd which prints working directory, but to my mind, it would have made more sense to name the variable $CWD for Current Working Directory, since shell variables contain data, rather than print them.

Tom Hale
  • 28,728
  • 32
  • 139
  • 229
  • Present working directory...but you said it. `print working directory` – jesse_b Oct 19 '17 at 02:14
  • @Jesse_b source? – Tom Hale Oct 19 '17 at 02:15
  • 12
    "The PWD shell variable was introduced by ksh88, where it was described as the present working directory." https://en.wikipedia.org/wiki/Pwd – jasonwryan Oct 19 '17 at 02:15
  • 6
    @jasonwryan, that looks like an answer. – Wildcard Oct 19 '17 at 02:27
  • 1
    The [SunOS 5.5.1 ksh manpage dated 1995](https://www.freebsd.org/cgi/man.cgi?query=ksh&apropos=0&sektion=1&manpath=SunOS+5.5.1&arch=default&format=html) uses "present working directory", but [the OpenBSD 2.0 ksh manpage (also dated 1995)](https://www.freebsd.org/cgi/man.cgi?query=ksh&apropos=0&sektion=1&manpath=OpenBSD+2.0&arch=default&format=html) uses "current working directory"... both were released in late 1996. Interesting. – muru Oct 19 '17 at 02:28
  • @Wildcard I voted to close as opinion based. – jasonwryan Oct 19 '17 at 02:37
  • 1
    @jasonwryan> The claim sounds dubious. The citation only links to the manpage of ksh88, which proves it did exist in ksh88, but absolutely doesn't prove it did not exist before. – spectras Oct 19 '17 at 02:41
  • @jasonwryan You could rewrite the question to make it one of history rather than opinion and then post your answer. – John1024 Oct 19 '17 at 02:49
  • @spectras of course it is dubious, it is wikipedia... – jasonwryan Oct 19 '17 at 02:58
  • @John1024 A rewrite won't save it; it is either "why is it called that", or "what does it stand for": in each case, it is subjective or unlikely to be authoratitively resolved by anyone here. – jasonwryan Oct 19 '17 at 03:00
  • 4
    FWIW, the *command* `pwd` is described as *“print working directory pathname”* in Thompson&Ritchie's UNIX Programmer's manual 5th edition, dated June 1974. And it's not in the 3rd edition. Alas, I cannot find a copy of 4th. – spectras Oct 19 '17 at 03:20
  • @spectras 4h edition (and earlier) did not have `pwd` it seems. – Kusalananda Oct 19 '17 at 05:49
  • 2
    `pwd` the utility and the `pwd` data structure field come from MULTICS. I believe `PWD` the environment variable was added on UNIX. It certainly predates `ksh88` though. – Satō Katsura Oct 19 '17 at 08:03
  • 1
    This is the kind of question that deals with angel's sex: "Why it's called PWD and not CWD?". Cause the creator of the command user print working dir as a verb(command), and makes sense to use a variable with the same name... –  Nov 03 '17 at 16:31
  • @jasonwryan If you make your comment an answer, I'll accept it. – Tom Hale Dec 17 '18 at 08:49

1 Answers1

4

It Is an acronym. The acronym is:
Print Working Directory

edit
Historically, program output was printed on paper rather than on screens. So the print part is due to the output technology of the time that the command was developed.

Shōgun8
  • 695
  • 5
  • 16
  • And the etymology? What is the source for you assertion? – Tom Hale Nov 03 '17 at 08:48
  • However @Sato has a good point, as a guide to multics written in 1980 shows the use of pwd as Print Working Directory http://multicians.org/multics-commands.html and this book agrees https://books.google.com/books?id=dFtY15Ng5xMC&pg=PA4&lpg=PA4&dq=multics+pwd&source=bl&ots=5bX9-kO1-s&sig=KEg2ydVMIEr72YVxO5PgpkrkjXI&hl=en&sa=X&ved=0ahUKEwiU_-ng06LXAhUV5WMKHUMpCzUQ6AEINzAD#v=onepage&q=multics%20pwd&f=false – Shōgun8 Nov 03 '17 at 14:49
  • And this may be the most telling yet: before Multics existed there was CTSS (both from MIT) and its output was printed on paper cards instead of Cathode Ray Tubes. So *Print* was the appropriate term of the day. http://www.linfo.org/pwd.html – Shōgun8 Nov 03 '17 at 15:27