Public domain Korn shell command interpreter (UNIX)
ksh [+-abCefhikmnprsuvxX] [+-o option] [ [ -c command-string [command-name] | -s | file ] [argument…] ]
QNX Neutrino, Linux, Microsoft Windows
You can specify the following options only on the command line:
In addition to the above, you can use the options described for the set builtin command on the command line.
The ksh is a public-domain version of the Korn shell. It's a command interpreter that's intended for both interactive and shell script use.
This shell isn't the same as the standard QNX 4 shell, which was modeled after ksh86. |
This description includes the following sections:
If neither the -c nor the -s option is specified, the first non-option argument specifies the name of a file the shell reads commands from; if there are no non-option arguments, the shell reads commands from standard input. The name of the shell (i.e. the contents of the $0 parameter) is determined as follows: if the -c option is used and there's a non-option argument, it's used as the name; if commands are being read from a file, the file is used as the name; otherwise the name the shell was called with (i.e. argv[0]) is used.
A shell is interactive if the -i option is used or if both standard input and standard error are attached to a tty. An interactive shell has job control enabled (if available), ignores the SIGINT, SIGQUIT and SIGTERM signals, and prints prompts before reading input (see PS1 and PS2 parameters). For noninteractive shells, the trackall option is on by default (see the set command below).
A shell is restricted if the -r option is used or if either the basename of the name the shell is invoked with or the SHELL parameter match the pattern *r*sh (e.g. rsh, rksh, and so on). The following restrictions come into effect after the shell processes any profile and $ENV files:
A shell is privileged if the -p option is used or if the real userid or group ID doesn't match the effective userid or group ID (see getuid(), and getgid()). A privileged shell doesn't process $HOME/.profile or the ENV environment variable (see below); instead it processes the /etc/suid_profile file. Clearing the privileged option causes the shell to set its effective userid (group ID) to its real userid (group ID).
If the basename of the name the shell is called with (i.e. argv[0]) starts with - or if the -l option is used, the shell is assumed to be a login shell, and the shell reads and executes the contents of /etc/profile and $HOME/.profile if they exist and are readable.
If the ENV environment variable is set when the shell starts (or, in the case of login shells, after any profiles are processed), its value is subjected to parameter, command, arithmetic and tilde substitution and the resulting file (if any) is read and executed. If ENV isn't set (and not null) and ksh was compiled with the DEFAULT_ENV macro defined, the file named in that macro is included (after the above mentioned substitutions have been performed).
The exit status of the shell is 127 if the command file specified on the command line couldn't be opened, or nonzero if a fatal syntax error occurred during the execution of a script. In the absence of fatal errors, the exit status is that of the last command executed, or zero, if no command is executed.
The shell begins parsing its input by breaking it into words. Words, which are sequences of characters, are delimited by unquoted whitespace characters (space, tab and newline) or meta-characters (<, >, |, ;, &, ( and )). Aside from delimiting words, spaces and tabs are ignored, while newlines usually delimit commands. The meta-characters are used in building the following tokens:
You can quote whitespace and meta-characters individually using backslash (\), or in groups using double (") or single (') quotes. Note that the following characters are also treated specially by the shell and you must quote them if they're to represent themselves:
An exception occurs when # is followed by !shell. This allows you to run a script using an alternative shell interpreter. E.g. if you have a C shell in /bin/csh, you can tell ksh to run your scripts using the C shell by starting the scripts with this:
#!/bin/csh
As words and tokens are parsed, the shell builds commands, of which there are two basic types: simple commands, typically programs that are executed, and compound commands, such as for and if statements, grouping constructs and function definitions.
A simple command consists of some combination of parameter assignments (see “Parameters,” below), input/output redirections (see “Input/output redirection,” below), and command words; the only restriction is that parameter assignments come before any command words. The command words, if any, define the command that's to be executed and its arguments. The command may be a shell builtin command, a function or an external command, i.e. a separate executable file that's located using the PATH parameter (see “Command execution and builtin commands,” below). Note that all command constructs have an exit status:
The exit status of a command consisting only of parameter assignments is that of the last command substitution performed during the parameter assignment, or zero if there were no command substitutions.
The ? special parameter stores the exit status of the last
nonasynchronous command.
For example, you can display the exit status by typing:
echo $?For more information, see “Parameters,” below. |
You can chain commands together using the | token to form pipelines in which the standard output of each command but the last is piped (see pipe()) to the standard input of the following command. The exit status of a pipeline is that of its last command. You can prefix a pipeline with the ! reserved word, which causes the exit status of the pipeline to be logically complemented: if the original status is 0 the complemented status is 1, and if the original status isn't 0, then the complemented status is 0.
You can create lists of commands by separating pipelines by any of the following tokens:
The && and || tokens have equal precedence, which is higher than that of &, |& and ;, which also have equal precedence.
Note that a command must follow the && and || operators, while a command need not follow &, |& and ;. The exit status of a list is that of the last command executed, with the exception of asynchronous lists, for which the exit status is 0.
Compound commands are created using the following reserved words. These words are recognized only if they're unquoted and are used as the first word of a command (i.e. you can't put any parameter assignments or redirections before them):
case else function then ! do esac if time [[ done fi in until { elif for select while }
Some shells (but not this one) execute control structure commands in a subshell when one or more of their file descriptors are redirected, so any environment changes inside them may fail. To avoid problems with portability, you should use the exec statement instead to redirect file descriptors before the control structure. |
In the following compound command descriptions, command lists (denoted as list) that are followed by reserved words must end with a semicolon, a newline or a (syntactically correct) reserved word. For example, these are valid:
{ echo foo; echo bar; } { echo foo; echo bar<newline>} { { echo foo; echo bar; } }
but this isn't:
{ echo foo; echo bar }
The commands are:
Patterns used in case statements are the same as those used for filename patterns, except that the restrictions regarding . and / are dropped. Note that any unquoted space before and after a pattern is stripped; you must quote any space within a pattern. Both the word and the patterns are subject to parameter, command, and arithmetic substitution as well as tilde substitution.
For historical reasons, you can use open and close braces instead of in and esac (e.g. case $foo { *) echo bar; }).
The exit status of a case statement is that of the executed list; if no list is executed, the exit status is zero.
For historical reasons, you can use open and close braces instead of do and done (e.g. for i; { echo $i; }).
The exit status of a for statement is the last exit status of list; if list is never executed, the exit status is zero.
The exit status of an if statement is that of the nonconditional list that's executed; if no nonconditional list is executed, the exit status is zero.
If you enter a blank line (i.e. zero or more IFS characters), the menu is reprinted without executing list. If REPLY is null when list completes, the enumerated list is printed, the prompt is printed and so on. This process is continues until an end-of-file is read, an interrupt is received or a break statement is executed inside the loop. If in word … is omitted, the positional parameters are used (i.e. $1, $2, and so on).
For historical reasons, you can use open and close braces instead of do and done (e.g. select i; { echo $i; }).
The exit status of a select statement is zero if a break statement is used to exit the loop, nonzero otherwise.
[ str ]
use:
[[ -n str ]]
[[ -r foo && $(< foo) = b*r ]]
the $(< foo) is evaluated if and only if the file foo exists and is readable.
Quoting is used to prevent the shell from treating characters or words specially:
If a \ inside a double-quoted string is followed by \, $, ` or ", it's replaced by the second character; if it's followed by a newline, both the \ and the newline are stripped; otherwise, both the \ and the character following are unchanged.
There are two types of aliases: normal command aliases and tracked aliases. Command aliases are normally used as shorthand for a long or often used command. The shell expands command aliases (i.e. substitutes the alias name for its value) when it reads the first word of a command. An expanded alias is reprocessed to check for more aliases. If a command alias ends in a space or tab, the following word is also checked for alias expansion. The alias expansion process stops when a word that isn't an alias is found, when a quoted word is found or when an alias word that's currently being expanded is found.
The shell automatically defines the following command aliases:
autoload='typeset -fu' functions='typeset -f' hash='alias -t' history='fc -l' integer='typeset -i' local='typeset' login='exec login' newgrp='exec newgrp' nohup='nohup ' r='fc -e -' stop='kill -STOP' suspend='kill -STOP $$' type='whence -v'
Tracked aliases allow the shell to remember where it found a particular command. The first time the shell does a path search for a command that's marked as a tracked alias, it saves the full path of the command. The next time the command is executed, the shell checks the saved path to see that it's still valid, and if so, avoids repeating the path search. You can create and list tracked aliases by using alias -t.
Changing the PATH parameter clears the saved paths for all tracked aliases. |
If the trackall option is set (i.e. set -o trackall or set -h), the shell tracks all commands. This option is set automatically for noninteractive shells. For interactive shells, only the following commands are automatically tracked: cat, cc, chmod, cp, date, grep, ls, make, mv, pr, rm, sed, sh, and who.
The first step the shell takes in executing a simple command is to perform substitutions on the words of the command. There are three kinds of substitution:
This substitution: | Takes the form: |
---|---|
Parameter | $name or ${…} (see “Parameters,” below) |
Command | $(command) or `command` |
Arithmetic | $((expression)) |
If a substitution appears outside of double quotes, the results of the substitution are generally subject to word or field splitting according to the current value of the IFS (internal field separators) parameter.
The IFS parameter specifies a list of characters that are used to break a string up into several words; any characters from the set space, tab and newline that appear in the IFS characters are called IFS whitespace. Sequences of one or more IFS whitespace characters, in combination with zero or one non-IFS whitespace characters delimit a field. As a special case, leading and trailing IFS whitespace is stripped (i.e no leading or trailing empty field is created by it); leading or trailing non-IFS whitespace does create an empty field.
For example: if IFS is set to <space>:, the sequence of characters <space>A<space>:<space><space>B::D contains four fields: A, B, an empty field, and D. Note that if the IFS parameter is set to the null string, no field splitting is done; if the parameter is unset, the default value of space, tab, and newline is used.
The results of substitution are, unless otherwise specified, also subject to brace expansion and filename expansion (see the relevant sections below).
A command substitution is replaced by the output generated by the specified command, which is run in a subshell. For $(command) substitutions, normal quoting rules are used when command is parsed, however, for the `command` form, a \ followed by any of $, ` or \ is stripped (a \ followed by any other character is unchanged).
As a special case in command substitutions, a command of the form < file is interpreted to mean substitute the contents of file. For example, $(< foo) has the same effect as $(cat foo), but the former is carried out more efficiently because no process is started.
$(command) expressions are currently parsed by finding the matching parenthesis, regardless of quoting. This will hopefully be fixed soon. |
Arithmetic substitutions are replaced by the value of the specified expression. For example, the command echo $((2+3*4)) prints 14. See “Arithmetic expressions” for a description of an expression.
Parameters are shell variables; you can assign values to them and access their values using a parameter substitution. A parameter name is either one of the special single punctuation or digit character parameters described below, or a letter followed by zero or more letters or digits (the underscore (_) counts as a letter). Parameter substitutions take the form $name or ${name}, where name is a parameter name. If substitution is performed on a parameter that isn't set, a null string is substituted unless the nounset option (set -o nounset or set -u) is set, in which case an error occurs.
You can assign values to parameters in a number of ways:
You must leave both the parameter name and the = unquoted for the shell to recognize a parameter assignment. |
Parameters with the export attribute (set using the export or typeset -x commands, or by parameter assignments followed by simple commands) are put in the environment (see environ() in the Library Reference) of commands run by the shell as name=value pairs. The order in which parameters appear in the environment of a command is unspecified. When the shell starts up, it extracts parameters and their values from its environment and automatically sets the export attribute for those parameters.
You can apply modifiers to the ${name} form of parameter substitution:
In the above modifiers, you can omit the :, in which case the conditions depend only on name's being set (as opposed to set and not null). If word is needed, parameter, command, arithmetic and tilde substitution are performed on it; if word isn't needed, it isn't evaluated.
You can also use the following forms of parameter substitution:
The shell implicitly set the following special parameters; you can't set them directly using assignments:
The shell sets and/or uses the following parameters:
If HISTFILE isn't set, no history file is used. This is different from the original Korn shell, which uses $HOME/.sh_history; in the future, ksh may also use a default history file. |
This parameter isn't imported from the environment when the shell is started. |
Note that since the command line editors try to figure out how long the prompt is (so they know how far it is to the edge of the screen), escape codes in the prompt tend to mess things up. You can tell the shell not to count certain sequences (such as escape codes) by prefixing your prompt with a nonprinting character (such as Ctrl-A) followed by a carriage return and then delimiting the escape codes with this nonprinting character. If you don't have any nonprinting characters, you're out of luck… BTW, don't blame me for this hack; it's in the original ksh. Default is $ for non-root users, # for root.
Tilde expansion, which is done in parallel with parameter substitution, is done on words starting with an unquoted ~. The characters following the tilde, up to the first slash (/), if any, are assumed to be a login name. If the login name is empty, + or -, the value of the HOME, PWD, or OLDPWD parameter is substituted, respectively. Otherwise, the password file is searched for the login name, and the tilde expression is substituted with the user's home directory. If the login name isn't found in the password file or if any quoting or parameter substitution occurs in the login name, no substitution is performed.
In parameter assignments (those preceding a simple command or those occurring in the arguments of alias, export, readonly, and typeset), tilde expansion is done after any unquoted colon (:), and login names are also delimited by colons.
The home directory of previously expanded login names are cached and reused. You can use the alias -d command to list, change and add directory aliases to this cache. For example:
alias -d fac=/usr/local/facilities; cd ~fac/bin
Brace expressions, which take the form:
prefix{str1,…,strN}suffix
are expanded to N words, each of which is the concatenation of prefix, stri and suffix. For example, a{c,b{X,Y},d}e expands to four words: ace, abXe, abYe, and ade). As noted in the example, you can nest brace expressions, and the resulting words aren't sorted. Brace expressions must contain an unquoted comma (,) for expansion to occur (i.e. {} and {foo} aren't expanded). Brace expansion is carried out after parameter substitution and before filename generation.
A filename pattern is a word containing one or more unquoted ? or * characters or […] sequences. Once brace expansion has been performed, the shell replaces filename patterns with the sorted names of all the files that match the pattern (if no files match, the word is left unchanged). The pattern elements have the following meanings:
Also, a ! appearing at the start of the list has special meaning (see below), so to represent itself, you must quote it or use it later in the list.
Note that ksh currently never matches . and .., but the original ksh, Bourne sh and bash do, so this may have to change (too bad).
Note that none of the above pattern elements match either a period (.) at the start of a filename or a slash (/), even if they are explicitly used in a […] sequence; also, the names . and .. are never matched, even by the pattern .*.
If the markdirs option is set, any directories that result from filename generation are marked with a trailing /.
The POSIX character classes (i.e [:class-name:] inside a […] expression) aren't yet implemented. |
When a command is executed, its standard input, standard output and standard error (file descriptors 0, 1 and 2, respectively) are normally inherited from the shell. Three exceptions to this are commands in pipelines, for which standard input and/or standard output are those set up by the pipeline, asynchronous commands created when job control is disabled, for which standard input is initially set to be from /dev/null, and commands for which any of the following redirections have been specified:
The line at the end of the “here document” must match marker exactly; it must not have any leading or trailing whitespace characters. |
If marker contains no quoted characters, the contents of the temporary file are processed as if enclosed in double quotes each time the command is executed, so parameter, command and arithmetic substitutions are performed, along with backslash (\) escapes for $, `, \ and \newline. If multiple here documents are used on the same command line, they're saved in order.
In any of the above redirections, you can explicitly give the file descriptor that's redirected (i.e. standard input or standard output) by preceding the redirection with a single digit. Parameter, command and arithmetic substitutions, tilde substitutions and filename generation are all performed on the file, marker and fd arguments of redirections. Note however, that the results of any filename generation are only used if a single file is matched; if multiple files match, the word with the unexpanded filename generation characters is used. Note that in restricted shells, you can't use redirections that can create files.
For simple commands, redirections may appear anywhere in the command; for compound commands (if statements, and so on), any redirections must appear at the end. Redirections are processed after pipelines are created and in the order they are given, so:
cat /foo/bar 2>&1 > /dev/null | cat -n
prints an error with a line number prepended to it.
You can use integer arithmetic expressions with the let command, inside $((…)) expressions, inside array references (e.g. name[expr]), as numeric arguments to the test command, and as the value of an assignment to an integer parameter.
Expressions may contain alphanumeric parameter identifiers, array references, and integer constants. You can combine expressions with the following C operators (listed and grouped in increasing order of precedence):
, = *= /= %= += -= <<= >>= &= ^= |= || && | ^ & == != < <= >= > << >> + - * / %
You can specify integer constants with arbitrary bases by using the notation base#number, where base is a decimal integer specifying the base, and number is a number in the specified base.
The operators are evaluated as follows:
var op= expr
is the same as:
var = var op ( expr )
A coprocess, which is a pipeline created with the |& operator, is an asynchronous process that the shell can both write to (using print -p) and read from (using read -p). The input and output of the coprocess can also be manipulated using >&p and <&p redirections, respectively. Once a coprocess has been started, another can't be started until the coprocess exits, or until the coprocess input has been redirected using an exec n>&p redirection. If a coprocess's input is redirected in this way, the next coprocess to be started shares the output with the first coprocess, unless the output of the initial coprocess has been redirected using an exec n<&p redirection.
Some notes concerning coprocesses:
This behavior is slightly different from the original Korn shell, which closes its copy of the write portion of the coprocess's output when the most recently started coprocess (instead of when all sharing coprocesses) exits. |
Functions are defined using either Korn shell function name syntax or the Bourne/POSIX shell name() syntax (see below for the difference between the two forms). Functions are like .-scripts in that they are executed in the current environment, however, unlike .-scripts, shell arguments (i.e. positional parameters, $1, and so on) are never visible inside them. When the shell is determining the location of a command, functions are searched after special builtin commands, and before regular and nonregular builtins, and before the PATH is searched.
You can delete an existing function by using unset -f function-name. You can list the functions by executing typeset +f, and list the function definitions by executing typeset -f. You can use the autoload command (which is an alias for typeset -fu) to create undefined functions; when an undefined function is executed, the shell searches the path specified in the FPATH parameter for a file with the same name as the function, which, if found is read and executed. If after executing the file, the named function is found to be defined, the function is executed, otherwise, the normal command search is continued (i.e. the shell searches the regular builtin command table and PATH). Note that if a command isn't found using PATH, the shell tries to autoload a function using FPATH (this is an undocumented feature of the original Korn shell).
Functions can have two attributes, trace and export, which you set with typeset -ft and typeset -fx. When a traced function is executed, the shell's xtrace option is turned on for the function's duration, otherwise the xtrace option is turned off. The export attribute of functions is currently not used. In the original Korn shell, exported functions are visible to shell scripts that are executed.
Since functions are executed in the current shell environment, parameter assignments made inside functions are visible after the function completes. If this isn't the desired effect, you can use the typeset command inside a function to create a local parameter. Note that special parameters (e.g. $$, $!) can't be scoped in this way.
The exit status of a function is that of the last command executed in the function. You can make a function finish immediately by using the return command; you can also use this to explicitly specify the exit status.
Functions defined with the function reserved word are treated differently in the following ways from functions defined with the () notation:
In the future, the following differences will also be added:
The shell is intended to be POSIX compliant, however, in some cases, POSIX behavior is contrary either to the original Korn shell behavior or to user convenience. How the shell behaves in these cases is determined by the state of the posix option (set -o posix); if it's on, the POSIX behavior is followed, otherwise it isn't. The posix option is set automatically when the shell starts up if the environment contains the POSIXLY_CORRECT parameter. (The shell can also be compiled so that it's in POSIX mode by default, however this usually isn't desirable).
The following is a list of things that are affected by the state of the posix option:
alias a='for ' i='j' a i in 1 2; do echo i=$i j=$j; done
uses parameter i in POSIX mode, but j in non-POSIX mode.
After evaluation of command-line arguments, redirections and parameter assignments, the command is checked to determine its type, in this order:
Special builtin commands differ from other commands in that the PATH parameter isn't used to find them, an error during their execution can cause a noninteractive shell to exit and parameter assignments that are specified before the command are kept after the command completes. Just to confuse things, if the posix option is turned off (see set command below) some special commands are very special in that no field splitting, file globing, brace expansion nor tilde expansion is performed on arguments that look like assignments. Regular builtin commands are different only in that the PATH parameter isn't used to find them.
The original ksh and POSIX differ somewhat in which commands are considered special or regular.
The POSIX special commands are:
Additional ksh special commands are:
The very special commands (non-POSIX mode) are:
The POSIX regular commands are:
The additional ksh regular commands are:
In the future, the additional ksh special and regular commands may be treated differently from the POSIX special and regular commands.
Once the type of the command has been determined, any command-line parameter assignments are performed and exported for the duration of the command.
The following sections describe the builtin commands:
. file [arg …]
Execute the commands in file in the current environment. The file is searched for in the directories of PATH. If arguments are given, you can use the positional parameters to access them while file is being executed. If no arguments are given, the positional parameters are those of the environment the command is used in.
: [ … ]
The null command. The exit status is set to zero.
alias [ -d | +-t [-r] ] [+-px] [+-] [name[=value] …]
Without arguments, alias lists all aliases. For any name without a value, the existing alias is listed. Any name with a value defines an alias (see “Aliases,” above).
When listing aliases, one of two formats is used:
In addition, if the -p option is used, each alias is prefixed with the string alias .
The -x option sets (+x clears) the export attribute of an alias, or, if no names are given, lists the aliases with the export attribute (exporting an alias has no affect).
The -t option indicates that tracked aliases are to be listed/set (values specified on the command line are ignored for tracked aliases). The -r option indicates that all tracked aliases are to be reset.
The -d option causes directory aliases, which are used in tilde expansion, to be listed or set (see “Tilde expansion,” above).
bg [job …]
Resume the specified stopped job(s) in the background. If no jobs are specified, %+ is assumed. This command is only available on systems that support job control. See “Job control,” below, for more information.
bind [-m] [key[=editing-command] …]
Set or view the current emacs command editing key bindings/macros. See “emacs interactive input-line editing,” below, for a complete description.
break [level]
Exit the levelth innermost for, select, until, or while loop. The level defaults to 1.
builtin command [arg …]
Execute the builtin command command. This is useful for explicitly executing the builtin version of commands (such as kill) that are also available as executable files.
cd [-LP] [dir]
Set the working directory to dir. If the parameter CDPATH is set, it lists the search path for the directory containing dir. A null path means the current directory. If dir is missing, the home directory $HOME is used. If dir is -, the previous working directory is used (see OLDPWD parameter). If -L option (logical path) is used or if the physical option (see the set command below) isn't set, references to .. in dir are relative to the path used to get to the directory. If -P option (physical path) is used or if the physical option is set, .. is relative to the filesystem directory tree. The PWD and OLDPWD parameters are updated to reflect the current and old working directory, respectively.
cd [-LP] old new
The string new is substituted for old in the current directory, and the shell attempts to change to the new directory.
command [-pvV] cmd [arg …]
If neither the -v nor -V option is given, cmd is executed exactly as if the command hadn't been specified, with two exceptions:
If you specify the -p option, a default search path is used instead of the current value of PATH. The actual value of the default path is system-dependent: on POSIXish systems, it's the value returned by:
getconf _CS_PATH
If the -v option is given, instead of executing cmd, information about what would be executed is given (and the same is done for arg …): for special and regular builtin commands and functions, their names are simply printed, for aliases, a command that defines them is printed, and for commands found by searching the PATH parameter, the full path of the command is printed. If no command is found, (i.e. the path search fails), nothing is printed and command exits with a nonzero status. The -V option is like the -v option, except it's more verbose.
continue [level]
Jump to the beginning of the levelth innermost for, select, until, or while loop. The level defaults to 1.
echo [-neE] [arg …]
Print the arguments (separated by spaces) followed by a newline, to standard output. The newline is suppressed if any of the arguments contain the backslash sequence \c. See the print command below for a list of other backslash sequences that are recognized.
The options are provided for compatibility with BSD shell scripts: -n suppresses the trailing newline, -e enables backslash interpretation (a no-op, since this is normally done), and -E suppresses backslash interpretation.
This command is also available as an executable; see echo.
eval command …
Concatenate the arguments (with spaces between them) to form a single string that the shell then parses and executes in the current environment.
exec [command [arg …]]
Execute the command without forking, replacing the shell process.
If no arguments are given, any IO redirection is permanent and the shell isn't replaced. Any file descriptors greater than 2 that are opened or duped in this way aren't made available to other executed commands (i.e. commands that aren't builtin to the shell). Note that the Bourne shell differs here: it does pass these file descriptors on.
exit [status]
Exit from the shell with the specified exit status. If status isn't specified, the exit status is the current value of the ? parameter.
export [-p] [parameter[=value]] …
Set the export attribute of the named parameters. Exported parameters are passed in the environment to executed commands. If values are specified, the named parameters also assigned.
If no parameters are specified, the names of all parameters with the export attribute are printed one per line, unless the -p option is used, in which case export commands defining all exported parameters, including their values, are printed.
false
A command that exits with a nonzero status.
This command is also available as an executable; see false.
fc [-e editor | -l [-n]] [-r] [first [last]]
The first and last arguments select commands from the history. You can select commands by history number, or a string specifying the most recent command starting with that string. The -l option lists the command on stdout, and -n inhibits the default command numbers. The -r option reverses the order of the list. Without -l, the selected commands are edited by the editor specified with the -e option, or if no -e is specified, the editor specified by the FCEDIT parameter (if this parameter isn't set, /bin/ed is used), and then executed by the shell.
fc [-e - | -s] [-g] [old=new] [prefix]
Reexecute the selected command (the previous command by default) after performing the optional substitution of old with new. If -g is specified, all occurrences of old are replaced with new. This command is usually accessed with the predefined alias r='fc -e -'.
fg [job …]
Resume the specified job(s) in the foreground. If no jobs are specified, %+ is assumed. This command is available only on systems that support job control. See “Job control,” below, for more information.
getopts optstring name [arg …]
The getopts command is used by shell procedures to parse the specified arguments (or positional parameters, if no arguments are given) and to check for legal options. The optstring argument contains the option letters that getopts is to recognize. If a letter is followed by a colon, the option is expected to have an argument. You can group options that don't take arguments into a single argument. If an option takes an argument and the option character isn't the last character of the argument it's found in, the remainder of the argument is taken to be the option's argument, otherwise, the next argument is the option's argument.
Each time getopts is invoked, it places the next option in the shell parameter name and the index of the next argument to be processed in the shell parameter OPTIND. If the option was introduced with a +, the option placed in name is prefixed with a +. When an option requires an argument, getopts places it in the shell parameter OPTARG. When an illegal option or a missing option argument is encountered, a question mark or a colon is placed in name (indicating an illegal option or missing argument, respectively) and OPTARG is set to the option character that caused the problem. An error message is also printed to standard error if optstring doesn't begin with a colon.
When the end of the options is encountered, getopts exits with a nonzero exit status. Options end at the first (non-option argument) argument that doesn't start with a -, or when a -- argument is encountered.
You can reset option parsing by setting OPTIND to 1 (this is done automatically whenever the shell or a shell procedure is invoked).
Changing the value of the shell parameter OPTIND to a value other than 1, or parsing different sets of arguments without resetting OPTIND may lead to unexpected results. |
hash [-r] [name …]
Without arguments, any hashed executable command pathnames are listed. The -r option causes all hashed commands to be removed from the hash table. If you specify any names, the shell searches for each one as if it were a command name, and adds the name to the hash table if it's an executable command.
jobs [-lpn] [job …]
Display information about the specified jobs; if no jobs are specified, all jobs are displayed. The -n option causes information to be displayed only for jobs that have changed state since the last notification. If the -l option is used, the process ID of each process in a job is also listed. The -p option causes only the process group of each job to be printed. See “Job control,” below, for the format of job and the displayed job.
kill [-s signame | -signum | -signame ] { job | pid | -pgrp } …
Send the specified signal to the specified jobs, process IDs, or process groups. If no signal is specified, the signal TERM is sent. If a job is specified, the signal is sent to the job's process group. See “Job control,” below, for the format of job.
kill -l [exit-status …]
Print the name of the signal that killed a process that exited with the specified exit-statuses. If no arguments are specified, a list of all the signals, their numbers and a short description of them are printed.
This command is also available as an executable; see kill.
let [expr …]
Evaluate each given expression (see “Arithmetic expressions,” above). If all expressions are successfully evaluated, the exit status is:
If an error occurs during the parsing or evaluation of an expression, the exit status is greater than 1.
Since expressions may need to be quoted, (( expr )) is syntactic sugar for let "expr".
print [-nprsun | -R [-en]] [argument …]
Print the arguments on the standard output, separated by spaces, and terminated with a newline. The -n option suppresses the newline. By default, certain C escapes are translated. These include \b, \f, \n, \r, \t, \v, and \0### (# is an octal digit, of which there may be 0 to 3). \c is equivalent to using the -n option. You can inhibit backslash expansion by using the -r option. The -s option prints to the history file instead of standard output, the -u option prints to file descriptor n (n defaults to 1 if omitted), and the -p option prints to the coprocess (see “Coprocesses,” above).
The -R option is used to emulate, to some degree, the BSD echo command, which doesn't process \ sequences unless the -e option is given. As above, the -n option suppresses the trailing newline.
pwd [-LP]
Print the present working directory. If -L option is used or if the physical option (see the set command below) isn't set, the logical path is printed (i.e. the path used to cd to the current directory). If -P option (physical path) is used or if the physical option is set, the path determined from the filesystem (by following .. directories to the root directory) is printed.
This command is also available as an executable; see pwd.
read [-prsun] [parameter …]
Read a line of input from standard input, separate the line into fields using the IFS parameter (see “Substitution,” above), and assign each field to the specified parameters. If there are more parameters than fields, the extra parameters are set to null, or alternatively, if there are more fields than parameters, the last parameter is assigned the remaining fields (inclusive of any separating spaces). If no parameters are specified, the REPLY parameter is used. If the input-line ends in a backslash and the -r option wasn't used, the backslash and newline are stripped and more input is read. If no input is read, read exits with a nonzero status.
The first parameter may have a question mark and a string appended to it, in which case the string is used as a prompt (printed to standard error before any input is read) if the input is a tty (e.g. read nfoo?'number of foos: ').
The -un and -p options cause input to be read from file descriptor n or the current coprocess (see “Coprocesses,” above, for comments on this), respectively. If the -s option is used, input is saved to the history file.
readonly [-p] [parameter[=value]] …
Set the readonly attribute of the named parameters. If values are given, parameters are set to them before setting the attribute. Once a parameter is made readonly, it can't be unset and its value can't be changed.
If no parameters are specified, the names of all parameters with the readonly attribute are printed one per line, unless the -p option is used, in which case readonly commands defining all readonly parameters, including their values, are printed.
return [status]
Return from a function or . script, with exit status status. If no status is given, the exit status of the last executed command is used. If used outside of a function or . script, it has the same effect as exit. Note that ksh treats both profile and $ENV files as . scripts, while the original Korn shell only treats profiles as . scripts.
set [+-abCefhiklmnprsuvxX] [+-o [option]] [+-A name] [--] [arg …]
You can use the set command to set (-) or clear (+) shell options, set the positional parameters, or set an array parameter. You can change options by using the +-o option syntax, where option is the long name of an option, or by using the +-letter syntax, where letter is the option's single letter name (not all options have a single letter name). The following table lists both option letters (if they exist) and long names along with a description of what the option does.
Letter | Long name | Description |
---|---|---|
-A | Sets the elements of the array parameter name to arg …; if -A is used, the array is reset (i.e. emptied) first; if +A is used, the first N elements are set (where N is the number of args), the rest are left untouched. | |
-a | allexport | All new parameters are created with the export attribute |
-b | notify | Print job notification messages asynchronously, instead of just before the prompt. Only used if job control is enabled (-m). |
-C | noclobber | Prevent > redirection from overwriting existing files (you must use >| to force an overwrite). |
-e | errexit | Exit (after executing the ERR trap) as soon as an error occurs or a command fails (i.e. exits with a nonzero status). This doesn't apply to commands whose exit status is explicitly tested by a shell construct such as if, until, while, && or || statements. |
-f | noglob | Don't expand filename patterns. |
-h | trackall | Create tracked aliases for all executed commands (see “Aliases,” above). On by default for noninteractive shells. |
-i | interactive | Enable interactive mode — this can only be set/unset when the shell is invoked. |
-k | keyword | Parameter assignments are recognized anywhere in a command. |
-l | login | The shell is a login shell — this can only be set/unset when the shell is invoked (see “Shell startup,” above). |
-m | monitor | Enable job control (default for interactive shells). |
-n | noexec | Don't execute any commands — useful for checking the syntax of scripts (ignored if interactive). |
-p | privileged | Set automatically if, when the shell starts, the read uid or gid doesn't match the effective uid or gid, respectively. See “Shell startup,” above for a description of what this means. |
-r | restricted | Enable restricted mode — this option can only be used when the shell is invoked. See “Shell startup,” above for a description of what this means. |
-s | stdin | If used when the shell is invoked, commands are read from
standard input.
Set automatically if the shell is invoked with no arguments.
When -s is used in the set command, it causes the specified arguments to be sorted before assigning them to the positional parameters (or to array name, if -A is used). |
-u | nounset | Referencing of an unset parameter is treated as an error, unless one of the -, + or = modifiers is used. |
-v | verbose | Write shell input to standard error as it's read. |
-x | xtrace | Print commands and parameter assignments when they are executed, preceded by the value of PS4. |
-X | markdirs | Mark directories with a trailing / during filename generation. |
bgnice | Background jobs are run with lower priority. | |
braceexpand | Enable brace expansion (also known as, alternation). | |
emacs | Enable BRL emacs-like command line editing (interactive shells only); see “emacs interactive input-line editing.” | |
gmacs | Enable gmacs-like (Gosling emacs) command line editing (interactive shells only); currently identical to emacs editing except that transpose (Ctrl-T) acts slightly differently. | |
ignoreeof | The shell won't exit on when end-of-file is read; you have to use exit. | |
nohup | Don't kill running jobs with a SIGHUP signal when a login shell exists. Currently set by default, but this will change in the future to be compatible with the original Korn shell (which doesn't have this option, but does send the SIGHUP signal). | |
nolog | No effect — in the original Korn shell, this prevents function definitions from being stored in the history file. | |
physical | Causes the cd and pwd commands to use physical (i.e. the filesystem's) .. directories instead of logical directories (i.e. the shell handles .., which allows the user to be oblivious of symlink links to directories). Clear by default. Note that setting this option doesn't effect the current value of the PWD parameter; only the cd command changes PWD. See the cd and pwd commands above for more details. | |
posix | Enable POSIX mode. See “POSIX mode,” above. |
These options can also be used upon invocation of the shell. You can find the current set of options (with single letter names) in the parameter -. The set -o command with no option name lists all the options and whether each is on or off; set +o prints the long names of all options that are currently on.
Remaining arguments, if any, are positional parameters and are assigned, in order, to the positional parameters (i.e. 1, 2, and so on). If options are ended with -- and there are no remaining arguments, all positional parameters are cleared. If no options or arguments are given, then the values of all names are printed. For unknown historical reasons, a lone - option is treated specially: it clears both the -x and -v options.
shift [number]
The positional parameters number+1, number+2 … are renamed to 1, 2, and so on. The number defaults to 1.
test expression
or:
[ expression ]
Evaluate the expression and return zero status if true, and 1 status if false and greater than 1 if there was an error. It's normally used as the condition command of if and while statements.
Calling an executable file test is a common mistake. If you don't specify the path to the file, the builtin command is executed. |
The following basic expressions are available:
[ X"str" != X ]
instead (double quotes are used in case str contains spaces or file globing characters).
[ -o foo -o -o !foo ]
returns true if and only if option foo exists).
You can combine the above basic expressions, in which unary operators have precedence over binary operators, with the following operators (listed in increasing order of precedence):
On operating systems not supporting /dev/fd/n devices (where n is a file descriptor number), the test command attempts to fake it for all tests that operate on files (except the -e test). That is, [ -w /dev/fd/2 ] tests if file descriptor 2 is writable.
Note that some special rules are applied (courtesy of POSIX) if the number of arguments to test or [ … ] is less than five: if leading ! arguments can be stripped such that only one argument remains, then a string length test is performed (again, even if the argument is a unary operator); if leading ! arguments can be stripped such that three arguments remain and the second argument is a binary operator, then the binary operation is performed (even if first argument is a unary operator, including an unstripped !).
A common mistake is to use if [ $foo = bar ], which fails if parameter foo is null or unset, if it has embedded spaces (i.e. IFS characters), or if it's a unary operator such as ! or -n. Use tests like if [ "X$foo" = Xbar ] instead. |
times
Print the accumulated user and system times used by the shell and by processes which have exited that the shell started.
trap [handler signal …]
Set the trap handler that's to be executed when any of the specified signals are received.
The handler is either a null string, indicating the signals are to be ignored, a minus (-), indicating that the default action is to be taken for the signals (see signal()), or a string containing shell commands to be evaluated and executed at the first opportunity (i.e. when the current command completes, or before printing the next PS1 prompt) after receipt of one of the signals.
The signal is the name of a signal (e.g. SIGPIPE or SIGALRM) or the number of the signal (see the kill -l command above). There are two special signals:
EXIT handlers are executed in the environment of the last executed command. Note that for noninteractive shells, the trap handler can't be changed for signals that were ignored when the shell started.
With no arguments, trap lists, as a series of trap commands, the current state of the traps that have been set since the shell started.
The original Korn shell's DEBUG trap and the handling of ERR and EXIT traps in functions aren't yet implemented. |
true
A command that exits with a zero value.
This command is also available as an executable; see true.
typeset [[+-Ulprtux] [-L[n]] [-R[n]] [-Z[n]] [-i[n]] | -f [-tux]] [name[=value] …]
Display or set parameter attributes. With no name arguments, parameter attributes are displayed: if no options are used, the current attributes of all parameters are printed as typeset commands; if an option is given (or - with no option letter) all parameters and their values with the specified attributes are printed; if options are introduced with +, parameter values aren't printed.
If name arguments are given, the attributes of the named parameters are set (-) or cleared (+). Values for parameters may optionally be specified. If typeset is used inside a function, any newly created parameters are local to the function.
When -f is used, typeset operates on the attributes of functions. As with parameters, if no names are given, functions are listed with their values (i.e. definitions) unless options are introduced with +, in which case only the function names are reported.
The options are:
For functions, -t is the trace attribute. When functions with the trace attribute are executed, the xtrace (-x) shell option is temporarily turned on.
For functions, -u is the undefined attribute. See “Functions,” above for the implications of this.
ulimit [-acdfHlmnpsStvw] [value]
Display or set process limits. If no options are used, the file size limit (-f) is assumed. The value, if specified, may be either be an arithmetic expression or the word unlimited. The limits affect the shell and any processes created by the shell after they're imposed. Note that some systems may not allow limits to be increased once they are set. Also note that the types of limits available are system dependent — some systems have only the -f limit.
The options are:
umask [-S] [mask]
Display or set the file permission creation mask, or umask (see umask). If the -S option is used, the mask displayed or set is symbolic, otherwise it's an octal number.
This command is also available as an executable; see umask.
Symbolic masks are like those used by chmod:
[ugoa]{{=+-}{rwx}*}+[,…]
in which the first group of characters is the who part, the second group is the op part, and the last group is the perm part. The who part specifies which part of the umask is to be modified. The letters mean:
The op part indicates how the who permissions are to be modified:
The perm part specifies which permissions are to be set, added or removed:
When symbolic masks are used, they describe what permissions may be made available (as opposed to octal masks in which a set bit means the corresponding bit is to be cleared). For example, ug=rwx,o= sets the mask so files won't be readable, writable or executable by “others”, and is equivalent (on most systems) to the octal mask 07.
unalias [-adt] [name …]
Remove the aliases for the given names. If the -a option is used, all aliases are removed. If the -t or -d option is used, the indicated operations are carried out on tracked or directory aliases, respectively.
unset [-fv] parameter …
Unset the named parameters (-v, the default) or functions (-f). The exit status is nonzero if any of the parameters were already unset, zero otherwise.
wait [job]
Wait for the specified job(s) to finish. The exit status of wait is that of the last specified job: if the last job is killed by a signal, the exit status is 128 + the number of the signal (see kill -l exit-status above); if the last specified job can't be found (because it never existed, or had already finished), the exit status of wait is 127. See “Job control,” below, for the format of job. The wait command returns if a signal for which a trap has been set is received, or if a SIGHUP, SIGINT or SIGQUIT signal is received.
If no jobs are specified, wait waits for all currently running jobs (if any) to finish and exits with a zero status. If job monitoring is enabled, the completion status of jobs is printed (this isn't the case when jobs are explicitly specified).
whence [-pv] [name …]
For each name, the type of command is listed (reserved word, builtin, alias, function, tracked alias or executable). If the -p option is used, a path search is done even if name is a reserved word, alias, and so on. Without the -v option, whence is similar to command -v except that whence finds reserved words and doesn't print aliases as alias commands; with the -v option, whence is the same as command -V. Note that for whence, the -p option doesn't affect the search path used, as it does for command. If the type of one or more of the names couldn't be determined, the exit status is nonzero.
Job control refers to the shell's ability to monitor and control jobs, which are processes or groups of processes created for commands or pipelines. At a minimum, the shell keeps track of the status of the background (i.e. asynchronous) jobs that currently exist; you can display this information by using the jobs command. If job control is fully enabled (using set -m or set -o monitor), as it is for interactive shells, the processes of a job are placed in their own process group, you can stop foreground jobs by typing the suspend character from the terminal (normally Ctrl-Z), you can restart jobs in either the foreground or background, using the fg and bg commands, and the state of the terminal is saved or restored when a foreground job is stopped or restarted.
Note that you can stop only commands that create processes (e.g. asynchronous commands, subshell commands, and nonbuiltin, nonfunction commands); you can't stop commands such as read.
When a job is created, it's assigned a job number. For interactive shells, this number is printed inside […], followed by the process IDs of the processes in the job when an asynchronous command is run. You can refer to a job in the bg, fg, jobs, kill and wait commands either by the process ID of the last process in the command pipeline (as stored in the $! parameter) or by prefixing the job number with a percent sign (%). You can also use other percent sequences to refer to jobs:
When a job changes state (e.g. a background job finishes or foreground job is stopped), the shell prints the following status information:
[number] flag status command
The fields are:
When an attempt is made to exit the shell while there are jobs in the stopped state, the shell warns the user that there are stopped jobs and doesn't exit. If another attempt is immediately made to exit the shell, the stopped jobs are sent a SIGHUP signal and the shell exits. Similarly, if the nohup option isn't set and there are running jobs when an attempt is made to exit a login shell, the shell warns the user and doesn't exit. If another attempt is immediately made to exit the shell, the running jobs are sent a SIGHUP signal and the shell exits.
When the emacs option is set, interactive input-line editing is enabled.
This mode is slightly different from the emacs mode in the original Korn shell; the 8th bit is stripped in emacs mode. |
In this mode, various editing commands (typically bound to one or more control characters) cause immediate actions without waiting for a new-line. Several editing commands are bound to particular control characters when the shell is invoked; you can use the following commands to change these bindings:
After invoking the bind command, typing the string causes the editing command to be immediately invoked. Note that although only two prefix characters (usually ESC and Ctrl-X) are supported, some multicharacter sequences can be supported. The following binds the arrow keys on an ANSI terminal, or xterm (these are in the default bindings). Of course some escape sequences won't work out quite this nicely:
bind '^[['=prefix-2 bind '^XA'=up-history bind '^XB'=down-history bind '^XC'=forward-char bind '^XD'=backward-char
The editing commands are listed below. Each description starts with the name of the command, a n (if you can prefix the command with a count), and any keys the command is bound to by default (written using caret notation, e.g. ASCII ESC character is written as ^[). You can enter a count prefix for a command by using the sequence ^[n, where n is a sequence of 1 or more digits; unless otherwise specified, if a count is omitted, it defaults to 1. Note that editing command names are used only with the bind command. Furthermore, many editing commands are useful only on terminals with a visible cursor. The default bindings were chosen to resemble corresponding emacs key bindings. The user's tty characters (e.g. ERASE) are bound to reasonable substitutes and override the default bindings.
Useful as a response to a request for a search-history pattern in order to abort the search.
Simply causes the character to appear as literal input. Most ordinary characters are bound to this.
Moves the cursor backward n characters.
Moves the cursor backward to the beginning of a word; words consist of alphanumerics, underscore (_) and dollar ($).
Moves to the beginning of the history.
Moves the cursor to the beginning of the edited input line.
Uppercase the first character in the next n words, leaving the cursor past the end of the last word.
If the current line doesn't begin with a comment character, one is added at the beginning of the line and the line is entered (as if return had been pressed), otherwise the existing comment characters are removed and the cursor is placed at the beginning of the line.
Automatically completes as much as is unique of the command name or the filename containing the cursor. If the entire remaining command or filename is unique, a space is printed after its completion, unless it's a directory name, in which case / is appended. If there is no command or filename with the current partial word as its prefix, a bell character is output (usually causing a audio beep).
Automatically completes as much as is unique of the command name having the partial word up to the cursor as its prefix, as in the complete command described above.
Automatically completes as much as is unique of the filename having the partial word up to the cursor as its prefix, as in the complete command described above.
List the possible completions for the current word.
Deletes n characters before the cursor.
Deletes n characters after the cursor.
Deletes n words before the cursor.
Deletes characters after the cursor up to the end of n words.
Scrolls the history buffer forward n lines (later). Each input line originally starts just after the last entry in the history buffer, so down-history isn't useful until either search-history or up-history has been performed.
Lowercases the next n words.
Moves to the end of the history.
Moves the cursor to the end of the input line.
Acts as an end-of-file; this is useful because edit-mode input disables normal terminal input canonicalization.
Acts as eot if alone on a line; otherwise acts as delete-char-forward.
Error (ring the bell).
Places the cursor where the mark is, and sets the mark to where the cursor was.
Appends a * to the current word and replaces the word with the result of performing file globbing on the word. If no files match the pattern, the bell is rung.
Moves the cursor forward n characters.
Moves the cursor forward to the end of the nth word.
Goes to history number n.
Deletes the entire input line.
Deletes the input between the cursor and the mark.
Deletes the input from the cursor to the end of the line if n is not specified, otherwise deletes characters between the cursor and column n.
Prints a sorted, columnated list of command names or filenames (if any) that can complete the partial word containing the cursor. Directory names have / appended to them.
Prints a sorted, columnated list of command names (if any) that can complete the partial word containing the cursor.
Prints a sorted, columnated list of filenames (if any) that can complete the partial word containing the cursor. File type indicators are appended as described under list above.
Causes the current input line to be processed by the shell. The current cursor position may be anywhere on the line.
Causes the current input line to be processed by the shell, and the next line from history becomes the current line. This is useful only after an up-history or search-history.
This does nothing.
Introduces a 2-character command sequence.
Introduces a 2-character command sequence.
The last (nth) word of the previous command is inserted at the cursor.
The following character is taken literally rather than as an editing command.
Reprints the prompt string and the current input line.
Search backward in the current line for the nth occurrence of the next character typed.
Search forward in the current line for the nth occurrence of the next character typed.
Enter incremental search mode. The internal history list is searched backwards for commands matching the input. An initial ^ in the search string anchors the search. The abort key leaves search mode. Other commands are executed after leaving search mode. Successive search-history commands continue searching backward to the next previous occurrence of the pattern. The history buffer retains only a finite number of lines; the oldest are discarded as necessary.
Set the mark at the cursor position.
On systems supporting it, pushes the bound character back onto the terminal input where it may receive special processing by the terminal handler. This is useful for the BRL ^T mini-systat feature, for example.
Acts like stuff, then aborts input the same as an interrupt.
If at the end of line, or if the gmacs option is set, this exchanges the two previous characters; otherwise, it exchanges the previous and current characters and moves the cursor one character to the right.
Scrolls the history buffer backward n lines (earlier).
Uppercases the next n words.
Display the version of ksh. The current edit buffer is restored as soon as any key is pressed (the key is then processed, unless it's a space).
Inserts the most recently killed text string at the current cursor position.
Immediately after a yank, replaces the inserted text string with the next previous killed text string.
This shell is based on the public domain 7th edition Bourne shell clone by Charles Forsyth and parts of the BRL shell by Doug A. Gwyn, Doug Kingston, Ron Natalie, Arnold Robbins, Lou Salkind and others. The first release of pdksh was created by Eric Gisin, and it was subsequently maintained by John R. MacMillan (chance!john@sq.sq.com), and Simon J. Gerraty (sjg@zen.void.oz.au). The current maintainer is Michael Rendell (michael@cs.mun.ca). The CONTRIBUTORS file in the source distribution contains a more complete list of people and their part in the shell's development.
Report any bugs in ksh to pdksh@cs.mun.ca. Please include the version of ksh (echo $KSH_VERSION shows it), the machine, operating system and compiler you are using and a description of how to repeat the bug (a small shell script that demonstrates the bug is best). The following, if relevant (if you aren't sure, include them), can also helpful: options you are using (both options.h options and set -o options) and a copy of your config.h (the file generated by the configure script). You can get new versions of ksh from ftp.cs.mun.ca:pub/pdksh/.
chmod, esh, fesh, gawk, getconf, rsh, sed, sh, stty, uesh, umask
dup(), environ(), errno, execve(), getgid(), getopt(), getuid(), open(), pipe(), rand(), signal(), system(), wait() in the Library Reference
Using the Command Line and Writing Shell Scripts in the Neutrino User's Guide
“Setting PATH and LD_LIBRARY_PATH” in the Configuring Your Environment chapter of the Neutrino User's Guide
The Korn Shell Command and Programming Language, Morris Bolsky and David Korn, 1989, ISBN 0-13-516972-0.
UNIX Shell Programming, Stephen G. Kochan, Patrick H. Wood, Hayden.
IEEE Standard for Information Technology — Portable Operating System Interface (POSIX) — Part 2: Shell and Utilities, IEEE Inc, 1993, ISBN 1-55937-255-9.