Skip to content

Know where you stand: the `pwd` program

Know where you stand: the `pwd` program

Details

This meetup concentrates on the common and simple commands; this time: pwd.

The pwd command prints your current working directory. We will start with a brisk walk through the Solaris pwd.c, then through the garden of BSD with Open, Net, and Free. After leaving the BSD brotherhood we trek on to the ksh, bash, and zsh builtins before landing in GNU.

With the many different authors and distinct cultures we will be sure to have much to discuss and compare. Some things to think about: The -P flag caused quite a stir; how do various programmers express this? In many cases this program is a wrapper around getcwd(); what complexities did getcwd() ignore that the program had to deal with? Why does this program exist?

The POSIX documentation on pwd:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pwd.html

Just in case you don't have eight copies of pwd.c sitting on your hard drive, you can find them online:

GNU Bash:

http://code.adamrisi.com/p/prestryke/source/tree/master/src/bash/bash-4.1/builtins/cd.def

FreeBSD:

http://svnweb.freebsd.org/base/head/bin/pwd/pwd.c?revision=141578&view=co

GNU:

http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/pwd.c

NetBSD:

http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/bin/pwd/pwd.c?rev=1.22

OpenBSD:

http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/bin/pwd/pwd.c?rev=1.11;content-type=text%2Fplain

pdksh:

https://github.com/bobertlo/openbsd-pdksh/blob/master/c_ksh.c#L161

OpenSolaris:

https://github.com/illumos/illumos-gate/blob/master/usr/src/cmd/pwd/pwd.c

zsh:

https://github.com/zsh-users/zsh/blob/master/Src/builtin.c#L669

This should all take about three hours. Food and drinks will be provided by thoughtbot (http://thoughtbot.se/).

About us:

This is a reading group for code. Our focus is the classics and tools we use every day. The inspiration is the shared metaphors and expressions we have in natural language due to common books (e.g. Hitchhiker's Guide to the Galaxy, Romeo and Juliet) and movies (e.g. Hackers, A Christmas Carol).

Photo of The Classical Code Reading Group of Stockholm group
The Classical Code Reading Group of Stockholm
See more events