KSH (1) January 1988 KSH (1) NAME ksh - Bourne / Korn Shell (Public Domain) SYNOPSIS pkshq [p-stq] [p-cq pcommandq] [pfileq [pargument ...q]] INTRODUCTION This document only summarizes the System V, release 2 shell features. All of the System V features except for "restricted mode" and the CDPATH and MAIL* variables 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. DESCRIPTION Command syntax The ``#'' character begins a one-line comment, unless the ``#'' occurs inside a word. The tokens ``;'', ``|'', ``&'', ``;;'', ``||'', ``&&'', ``('', and ``)'' stand by themselves. A pwordq is a sequence of any other non-whitespace characters, which may also contain quoted strings (quote character are ``º'', ``"'', ```'', or a matching ``${ }'' or ``$( )'' pair). A pnameq is an unquoted word made up of letters, digits, or ``_''. Any number of whitespace characters (space and tab) may separate words and tokens. In the following syntax, { ... }? indicates an optional thing, { ... }* indicates zero or more repetitions, { ... | ... } indicates alternatives. statement: p(q list p)q p{q list p;q p}q pforq name { pinq { word }* }? pdoq list p;q pdoneq pwhileq | puntilq } list p;q pdoq list p;q pdoneq pifq list p;q pthenq list p;q { pelifq list p;q pthenq list p;q }* { pelseq list p;q }?pfiq pcaseq name pinq { p(q word { p|q word } p)q list p;;q }* pesacq pfunctionq name p{q list p;q p}q 0me p() {q list p;q p}q ptimeq 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: Sun May 19 22:02:47 1991 Page 1 KSH (1) January 1988 KSH (1) ond ond p;q list ond p&q list cond: ipe ipe p&&q cond ipe p||q cond pipe: tatement { p|q statement }* Alias expansion 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. Shell variables The following standard special variables exist: p!q, p#q, p$q, p-q, p?q. CDPATH Not yet implemented. ENV If this variable is set at start-up (after any profile 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 pfcq command. IFS pInternal field separatorq, used during substitution and the preadq command. HOME The default directory for the pcdq command. MAIL MAILCHECK MAILPATH Not yet implemented. PATH The search path for executable commands and p.q'd files. PS1 PS2 pPS1q is the primary prompt for interactive shells. Dollar substitution is performed, and p!q is replaced with the command number (see pfcq). PWD OLDPWD Sun May 19 22:02:47 1991 Page 2 KSH (1) January 1988 KSH (1) The current and previous working directories. SECONDS The number of seconds since the shell was started. Substitution In addition to the System Vr2 substitutions, the following are available. $(command) Like `command`, but no escapes are recognized. $( with the SIG prefix removed. let [pexpression ...q] Each expression is evaluated, see "Expressions" above. A zero status is returned if the last expression evaluates to a non-zero value, otherwise a non-zero status is returned. pprintq [p-nreupnq] [pargument ...q] pPrintq prints its arguments on the standard output, separated by spaces, and terminated with a newline. The p-nq option eliminates the newline. By default, certain C escapes are translated. These include \b, \f, \n, \r, \t, \v, and \### (# is an octal digit). \c is equivalent to the p-nq option. This expansion may be inhibitted with the p-rq option, and may be re-enabled with the addition of the p-eq option. read [p-rupnq] pname ...q The first variable name may be of the form pnamep?ppromptq. readonly [pname ...q] return [pstatusq] ***nroff: unrecognized command .ta 5n 10n 30n set [pñqp[a-z]q] [pñoq pkeywordq] ... Set (p-q) or clear (p+q) a shell option: -a llexport ll new variable are created with export attribute -e \rrexit \xit on non-zero status [incorrect] ***nroff: no register match