MPE/iX Shell and Utilities Reference Manual, Vol 2
sh(1) MPE/iX Shell and Utilities sh(1)
The following implements the basename(1) utility as a shell function.
# basename utility as shell function
function basename {
case $# in
1) ;;
2) eval set \${1%$2} ;;
*) echo Usage: $0 pathname ’[suffix]’
return 1 ;;
esac
echo ${1##*/}
return 0
}
ENVIRONMENT VARIABLES
sh uses the following environment variables:
_
(underscore) expands to the last argument from the previously executed command.
For every command that is executed as a child of the shell, sh sets this variable to
the full path name of the executable file and passes this value through the environ-
ment to that child process. When processing the
MAILPATH
variable, this variable
holds the value of the corresponding mail file.
CDPATH
contains a list of directories for the cd(1) command to search. Directory names are
separated with colons.
CDPATH
works in a similar way to the
PATH
variable.
COLUMNS
contains the maximum width of the edit window in the KornShell’s Vi or EMACS
edit-
ing mode. It is also used by several other commands to define the width of the termi-
nal output device.
EDITOR
when ending with any of vi, emacs,orgmacs, enables the corresponding editing
mode (see set(1), shedit(3)).
ERRNO
contains the system error number of the most recently failed system call. The shell
only sets this variable for errors which occur in the current environment. Assigning a
value of 0 to this variable clears it.
ENV
contains a value that sh performs parameter substitution on and uses the result as the
name of an initialization file. This file is executed with the . command (see dot(1)).
This facility lets you define functions (see Command Syntax), aliases (see
alias(1)), and other non-exported items during shell initialization.
1-542 Commands and Utilities