Description of Predefined Shell Variables

The following variables have special meaning to gsh. Shell variable names are not case sensitive.

$0, $1, $2, ...

String values that contain the arguments to a shell script. Variable 0 contains the name of the script. The first argument begins with variable 1 and so on.

$<

When encountered, the variable is expanded using a value obtained from standard input. This provides a means of obtaining user input in script files. Note that the shell variables are expanded before the command-line is executed (See the Section called Accessing Shell Variables.) When prompting the user for input, be sure that the prompt is in a separate command-line than the $<. Also, if the user wishes to enter a value with spaces, he must quote what he types with double-quotes.

$ECHO

A boolean value that, if defined, will cause commands in a shell script to be echoed to standard output.

$FIGNORE

This variable, if set, contains a list of filename suffixes. When doing command or filename completion, gsh will ignore any filename with a suffix listed in FIGNORE. For example, you might want to set fignore=".A .ROOT .SYM" to ignore object files and other compiler droppings.

$HISTORY

A numeric value that contains the number of history commands (command-lines) remembered. If the value is 0 or HISTORY is undefined, all commands will be remembered. Previous command-lines can be called back with the UP-ARROW and DOWN-ARROW. (See the Section called History Editing in the Chapter called Interacting with the GNO Shell.)

$HOME

The HOME directory is the main directory of the shell; it is the directory gsh defaults to when it starts. The tilde ("~") character can be used as a shorthand method of accessing the HOME directory (as discussed in the Section called Pathname Expansion in the Chapter called Using the GNO Shell More Productively).

$IGNOREEOF

A boolean value that, if enabled, will prevent ^D from exiting the shell.

$NOBEEP

A boolean value that, if set, will prevent gsh from sounding the speaker when errors occur while editing a command-line.

$NODIREXEC

A boolean value that, if set, will disable gsh's feature of treating directory names as commands; i.e. if a directory is specified as a command, gsh will move to that directory as though the cd command was being used.

$NOGLOB

A boolean value that, if set, will disable filename globbing. Command arguments will be passed to their commands "as-is", without any wildcard expansion.

$NONEWLINE

A boolean value that, if set, will disable extraneous carriage returns being output before and after command execution. Examples given in this manual have this option set.

$PATH

A string value that defines the pathnames where shell scripts, EXE utilities, and SYS16 programs can be found (See the Section called How gsh Finds a Command in the Chapter called Using the GNO Shell More Productively). Because GS/OS uses colons as separators in pathnames, gsh cannot allow colons to be used as separators in the PATH variable, as UNIX does. If one of the path entries has a space within it (which is possible with the HFS FST), then the space should be quoted with a backslash, "\".

$PRECMD

This is actually a special alias and not an environment variable. If PRECMD is defined then its value is taken as a a command to be executed just before gsh prints the prompt for a command line. For example, alias precmd qtime will print the time in English text before every prompt.

$PROMPT

When gsh prompts you to enter a command, the prompt that appears before the cursor can be customized for your gsh environment. If PROMPT is undefined, the default prompt of "% " is used. The prompt string recognizes certain character sequences in the PROMPT variable and interprets them accordingly. The following are the special characters:

Table 1. Prompt Special Characters

%h, %!, !current history number
%t, %@current time of day in 12 hour am/pm format
%d, %/current working directory
%~current working directory with tilde replacement
%c, %C, %.trailing component of current working directory
%S, %sinverse mode on (%s) and off (%S)
%U, %u begin and end underline mode (only on terminals that support underline; gnocon will use inverse mode instead)
%%the single "%" character
%nuser name (as defined by $USER)
%Wdate in mm/dd/yy format
%Ddate in yy-mm-dd format
\nnewline
\rcarriage return
\thorizontal tab
\bbell

$PUSHDSILENT

If this variable is defined, gsh will not print the directory stack after any of the directory stack commands. (See pushd and popd in the Section called Builtin Shell Commands in the Chapter called Builtin Command Reference.)

$SAVEHIST

A numeric value that contains the number of commands to save to disk when exiting gsh. These commands are then read back in when gsh is restarted which allows old commands to be reused. If the value is 0 or SAVEHIST is undefined, no commands will be saved to disk.

$TERM

This variable contains the name of the terminal emulation that the shell and other applications should use. By default, it is "gnocon". When the shell encounters a set term command, it automatically calls the the tset to reload the termcap information. See also the Appendix called Termcaps.

$TERMCAP

This variable specifies the location of the termcap file. The shell and other applications look for termcap in the /etc directory, but if TERMCAP is set, the fully specified termcap file is used instead. This allows users to install custom termcap entries. See also the Appendix called Termcaps.

$USER

A string that represents the login name of the current user. This variable is usually set by login(8).