Shellvarnia: Shell Variables Down Unix

Political map showing Shellvarnia on the left side of the continent, Flapjackia, separated from Userland (on the east coast of Flapjackia) by Environmentopia in the middle. No direct connection between Shellvarnia and Userland is shown.

Political map of continent, Flapjackia, showing countries of Shellvarnia, Environmentopia, and Userland.

This is a fun short story about the fictional land of Shellvarnia, located Down Unix, that occurred to me one night while I was reading Brian Ward‘s excellent book, How Linux Works: What Every Superuser Should Know. Mixing one dash of political satire with a heaping serving of Unix lore, it will entertain and inform novices approaching a Linux VM for the first time.  If you’ve ever wondered about distinctions between local shell variables and environment variables, /bin/sh from /bin/csh, and who built that wall between Shellvarnia and Environmentopia, then this story was written just for you. 

In the Beginning, Bourne Created the Shell Variable

The creation myth started in the early days of Bell Labs, at an International House of Pancakes restaurant in Murray Hill, New Jersey.  Master programmers such as Ken Thompson, Stephen Bourne, Bill Joy, and numerous others, sat around a booth on National Pancake Day reflecting upon how everything began.  Over a hot brew of coffee, we take up that fantastic story.

It is from their labors that we have today, the continent of Flapjackia.  An amazing short-stack of pancakes situated “Down Unix” by the Maple Syrup Sea.  Alas, newcomers to Flapjackia find some of the local customs confusing, unaware of how they came to be this way.  They wish their user processes in Userland would run in harmony, alongside all of the other user processes, but they always stop before they can begin with errors like “variable ‘x’ not found.

If you ask them, they will swear to you that they typed:

$ set X=/usr/bin/xampp

but that it just isn’t working for them.  They haven’t heard the story about the divide between Shellvarnia and Environmentopia.


Using pancakes to illustrate two globules of butter, representing variables beginning with a dollar-sign. While the environment variables have access to Userland across their shared border, the local shell variables on the western pancake of Shellvarnia are blocked by a wall of strawberries and a maple syrup sea.

Even though shell variables look like environment variables, they are inaccessible to user processes running over in Userland.

Environmentopia is a happy pancake in which many variables reside, regularly commuting to their day jobs in Userland across the Blueberry Mountains.  It is important to note that Environmentopia is not smaller than the other pancakes, nor is Flapjackia meant to resemble the real-world continent of Australia. My little sister just took a bite out of the pancake before I could take a picture of it.  “meh-Lis-SAH!”

Like any Unix variable, they start with a dollar-sign, and by convention are always written in all-caps.  $PATH, $LANG, and many others convey important information that is shared by the many processes of Userland started from a particular shell.  Unfortunately, relations between Environmentopia and it’s neighbor across the border to the west, Shellvarnia, could be better.


Shellvarnia is the pancake that has had it all, all of the shell variables came from here at one time or another, and they exhibit great diversity.  Shellvarnia is home to many different flavors of Unix shell, the two most powerful being the left-leaning party of the Bourne shell (/bin/sh) and the right-leaning party of the C shell (/bin/csh).  While they are alike in many ways, they disagreed and argued over issues such as whether they should be all-caps or all-lowercase.  This made the Congress of Shellvarnia a very devisive place, even though commerce with neighboring Environmentopia was immensely important to their economy.

One day the OS rebooted, and some red state variable from nowhere named $murpt rose to power on a platform promising to “repeal-and-replace” stderr, an ld symbol import ban until we know “WTF” is going on, and an entourage of unstable static libraries, believed to have been coded in Russia.  Conspiracy theorists saw rival Russian hackers subverting us into renaming the pancakes of Flapjackia blini.  While these allegations distracted everyone with virtually constant media coverage on the cooking channels, $murpt carried through on his promises. He built a Wall of Raspberries along the length of the border between Shellvarnia and Environmentopia.  Then he made the Raspberry Pi programmers pay for it!

The whole of Flapjackia grew nervous by the sudden reversal of system policy witnessed in Shellvarnia, and expert users collaborated on solutions off-site at places like Stack Exchange for allowing access of local shell variables from Shellvarnia to continue sharing their important data with user processes in Userland.

Legally Crossing the Border

Using pancakes to illustrate how a shell variable can cross the maple syrup sea from Shellvarnia to Userland across the tynes of a fork, representing the CLI special shell variables $0, $1, $2, etc., given to command-line arguments.

One solution to supplying shell variables to user processes is via the packaging them as special variables $0, $1, $2, etc. passed as arguments via the Command Line Interface (CLI).

The international Unix and Linux user community adopted a few practices for legally crossing from Shellvarnia to neighboring pancakes, despite the Wall.  These are exporting, creating the variable using setenv, and/or passing the values of shell variables as arguments over the command line interface (CLI).

It’s important every new Unix and Linux user learn these well, to avoid errors or unexpected behavior when crossing this border.


Users of Bourne (and Bourne-again or bash) shells can use the export statement to send their local shell variables across the border into Environmentopia.  For example,

$ set X=/usr/bin/xampp

export X


Users of C (and TENEX C shell or tcsh) shells can use the setenv statement to both intiialize and export a shell variables across the border into Environmentopia.  By convention, exported variables are all uppercase (instead of all lowercase) to easily differentiate them from local C shell variables.  For example,

$ setenv X /usr/bin/xampp

command line arguments

Free market forces led CLI cruise lines to offer a service ferrying shell variable values from Shellvarnia across the Maple Syrup Sea to Userland (as shown by the fork in Figure 3). Just pass your shell variables on the command-line, and they will be received in Userland as special shell variables $0, $1, $2, …

$ $X

User processes can access these values as they do their ordinary command-line arguments, unaware they used to be local shell variables originating from Shellvarnia.


When in doubt about the validity of any border crossing, users can print a list of the environment variables on screen known to be valid in Environmentopia.


Clearly, many options remain open for exposing shell variables to Userland.  But then what did you expect?  This wall was made out of raspberries.


If you grew used to globalization in the other operating systems you’ve used for computing, be prepared to put that aside in your future dealings with the residents of Shellvarnia.  A Schengen style solution is unlikely in the near future, but on the bright side, so long as you follow proper procedures and have your paperwork ready, your local shell variables can continue conveying their precious information to user processes in Userland.  May Bourne have mercy on the rest of us.

Pancakes fueling this blog article were graciously provided by the International House of Pancakes on today, March 7, 2017, National Pancake Day.  Stop by your local IHOP for a free short stack of pancakes, and to donate to the fight against children’s leukemia and lymphoma.

Comments are closed.