Datasheet

Shell Features
Shells vary greatly in appearance and functionality, but each of them presents some form of a prompt to
let you know that it’s waiting for you to issue a command. In general, you type a command following the
prompt and press the Enter key to submit the command to the shell. When you are working in a shell,
there is always one directory that is considered your current working directory. Most shell prompts con-
tain that directory to make it easier for you to keep your bearings as you move from directory to directory.
For example, a typical prompt in Windows shells may look something like the following:
C:\Program Files>
and in Unix-type shells, something like the following:
mozart maryann /usr/local/bin>
To exit the shell, type exit and press Enter.
The Environment
Each shell also has a pool of variables, known as the environment, available to programs. The environ-
ment typically holds information about where the system should look for programs and libraries, what
the shell prompt should look like, and so forth. You can view this information by issuing the following
command at the shell prompt:
set
Regardless of the platform you use, you will want to modify the shell environment to let Lua know
where to find extension modules. Additionally, if you intend to compile Lua or libraries, you’ll need to
set up environment variables that your SDK will look for.
Environment Variables on Unix-Like Systems
On Unix-like systems, you generally modify the shell environment in one of the shell startup scripts. For
example, if you use the
bash shell, it will process /etc/bashrc and, in your home directory, .bashrc
when it starts. The first file is used for system-wide settings, and the second is used for your own private
settings. You’ll need root privileges to modify the first. Within these files, you set an environment vari-
able by including a line that looks like the following:
export LUA_DIR=/usr/local/lib/lua/5.1
When you reference environment variables in shell scripts, you precede the name with $, as in echo
$LUA_DIR
.
In this book, the following environment variables are recommended for Unix-like systems:
LUA_DIR=/usr/local/lib/lua/5.1
LUA_CPATH=?.so;$LUA_DIR/?.so
LUA_PATH=?.lua;$LUA_DIR/?.lua
Restart the shell for changes to take effect.
4
Chapter 1: Getting Situated
04_069172 ch01.qxp 1/2/07 7:53 PM Page 4