Setting Shell Environment Variables

An environment variable is a magical piece of invisible data that is acted upon by shell programs and utilities that look for its existence. They’re innocent enough and you rarely interact with them, but they can prove to be quite powerful and time saving when used as part of your daily lifestyle.

Smart developers who care about code integrity use something called a versioning system to ensure a system of checks and balances, easy reversion to previous code, and preventive overwriting (by an automatic or manual merging process). It’s such a common part of a developer’s toolkit that the popular open source web IDE Sourceforge.net provides it as a default service.

One annoyance of Concurrent Versioning System (CVS) (longtime users can find many more) is the command line — without an enviroment variable, you have to type your cvsroot each and every time you make any changes to your repository:

cvs -d:pserver:anonymous@cvs.amphetadesk.sourceforge.net:/cvsroot/amphetadesk login
cvs -z3 -d:pserver:anonymous@cvs.amphetadesk.sourceforge.net:/cvsroot/amphetadesk co AmphetaDesk

These two lines log you into a CVS server as the user anonymous and then check out the entire source tree of a program called AmphetaDesk. A cursory examination shows that the largest part of the command line is the -d flag; it’s also repetitive, as it needs to be a part of every cvs command. It can make a person nuts when she has to worry about committing modifications to ...

Get Mac OS X Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.