home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
useful
/
dist
/
util
/
shell
/
pdksh
/
ksh.man
< prev
next >
Wrap
Text File
|
1993-12-01
|
52KB
|
1,255 lines
KSH(1) KSH(1)
NNAAMMEE
ksh - Bourne / Korn Shell (Public Domain)
SSYYNNOOPPSSIISS
kksshh [--sstt] [--cc _c_o_m_m_a_n_d] [_f_i_l_e [_a_r_g_u_m_e_n_t _._._.]]
IINNTTRROODDUUCCTTIIOONN
This document only summarizes the System V, release 2
shell features. All of the System V features except for
``restricted mode'' are implemented. See also the BUGS
section.
Features of the Korn shell are described in more detail.
Only a subset of the Korn shell features are currently
implemented.
DDEESSCCRRIIPPTTIIOONN
CCoommmmaanndd ssyynnttaaxx
The ``#'' character begins a one-line comment, unless the
``#'' occurs inside a word. The tokens ``;'', ``|'',
``&'', ``;;'', ``||'', ``&&'', ``('', and ``)'' stand by
themselves. A _w_o_r_d is a sequence of any other non-
whitespace characters, which may also contain quoted
strings (quote character are ``''', ``"'', ```'', or a
matching ``${ }'' or ``$( )'' pair). A _n_a_m_e is an
unquoted word made up of letters, digits, or ``_''. Any
number of whitespace characters (space and tab) may sepa-
rate words and tokens.
In the following syntax, { ... }? indicates an optional
thing, { ... }* indicates zero or more repetitions, { ...
| ... } indicates alternatives.
statement:
(( list ))
{{ list ;; }}
ffoorr name { iinn { word }* }? ddoo list ;; ddoonnee
{ wwhhiillee | uunnttiill } list ;; ddoo list ;; ddoonnee
iiff list ;; tthheenn list ;; { eelliiff list ;; tthheenn list ;; }*
{ eellssee list ;; }?ffii
ccaassee name iinn { (( word { || word } )) list ;;;; }* eessaacc
ffuunnccttiioonn name {{ list ;; }}
name (()) {{ list ;; }}
ttiimmee pipe
The opening parenthesis of the pattern is optional.
Redirection may occur at the beginning or end of a
statement.
command:
{ name=word }* { word }*
Redirection may occur anywhere in a command.
list:
cond
April 1992 1
KSH(1) KSH(1)
cond ;; list
cond && list
cond:
pipe
pipe &&&& cond
pipe |||| cond
pipe:
statement { || statement }*
AAlliiaass eexxppaannssiioonn
Alias expansion occurs when the first word of a statement
is a defined alias, except when that alias is already
being expanded. It also occurs after the expansion of an
alias whose definition ends with a space.
SShheellll vvaarriiaabblleess
The following standard special variables exist: !!, ##, $$,
--, ??.
_ In interactive use this parameter is set to the
last word of the previous command. When a command
is executed this parameter is set to the full path
of the command and placed in the environment for
the command. See also MMAAIILLPPAATTHH.
CDPATH The search path for the _c_d command.
ENV If this variable is set at start-up (after any pro-
file files are executed), the expanded value is
used as shell start-up file. It typically contains
function and alias definitions.
FCEDIT The editor used by the _f_c command. During startup
the shell checks the value of FFCCEEDDIITT, EEDDIITTOORR and
finally VVIISSUUAALL to try and determin what command
line edit mode to use. Note that this is not
strictly ksh compatible behaviour.
IFS _I_n_t_e_r_n_a_l _f_i_e_l_d _s_e_p_a_r_a_t_o_r, used during substitution
and the _r_e_a_d command.
HOME The default directory for the _c_d command.
MAIL If set, the user will be informed of the arrival of
mail in the named file. This variable is ignored
if the MMAAIILLPPAATTHH variable is set.
MAILCHECK
How often, in seconds, the shell will check for
mail in the file(s) specified by MMAAIILL or MMAAIILLPPAATTHH.
If 0, the shell checks before each prompt. The
default is 600 seconds.
April 1992 2
KSH(1) KSH(1)
MAILPATH
A list of files to be checked for mail. The list
is colon separated, and each file may be followed
by a ?? and a message to be printed if new mail has
arrived. Command and parameter substitution is
performed on the message, and the parameter $$__ is
set to the name of the file. The default message
is ``you have mail in $_''.
PATH The search path for executable commands and ..'d
files.
PPID The process number of the parent of the shell.
PS1 PS2
PPSS11 is the primary prompt for interactive shells.
Dollar substitution is performed, and !! is replaced
with the command number (see _f_c).
PWD OLDPWD
The current and previous working directories.
RANDOM A random integer. The random number generator may
be seeded by assigning an integer value to this
variable.
SECONDS
The number of seconds since the shell timer was
started or reset. Assigning an integer value to
this variable resets the timer.
COLUMNS
The width to use for the commandline editing (emacs
mode only).
HISTFILE
The name of the file to read initial history from.
The default is "$$HHOOMMEE//..ppddkksshh__hhiisstt". When the shell
exits it will overwrite this file with its current
history. This behaviour will almost certainly
cause grief when multiple shells are being run by
the same user. Making the file read-only will
allow each shell to start with a set history and
avoid overwriting the file.
HISTSIZE
The number of history items to save in HHIISSTTFFIILLEE.
SSuubbssttiittuuttiioonn
In addition to the System Vr2 substitutions, the following
are available.
$(command)
Like `command`, but no escapes are recognized.
April 1992 3
KSH(1) KSH(1)
$(<file)
Equivalent to $(cat file), but without forking.
${#var}
The length of the string value of _v_a_r, or the num-
ber of arguments if _v_a_r is ** or @@.
${var#pattern} ${var##pattern}
If _p_a_t_t_e_r_n matches the beginning of the value of
_v_a_r, the matched text is deleted from the result of
substitution. A single ## results in the shortest
match, two ##'s results in the longest match.
${var%pattern} ${var%%pattern}
Like ## substition, but deleting from the end of the
value.
EExxpprreessssiioonnss
Expressions can be