Annotation of coherent/a/usr/bob/korn/ksh.1, revision 1.1.1.1

1.1       root        1: .nr OJ 1 \" Job Control
                      2: .nr OE 1 \" Command Editing
                      3: .nr OB 1 \" BSD enhanced ulimit options
                      4: .ds OK [\|
                      5: .ds CK \|]
                      6: .TH KSH "MWC In-House Docs"
                      7: .SH NAME
                      8: ksh \- Korn Shell (Public Domain)
                      9: .SH SYNOPSIS
                     10: \fBksh\fP
                     11: [\fB\-\fIset_options\fR] [\fB\-st\fP] [\fB\-c\fP \fIcommand\fP]
                     12: [\fIfile\fP [\fIargument ...\fP]]
                     13: .SH INTRODUCTION
                     14: This document only summarizes the System V, release 2 shell features.
                     15: All of the System V features except for "restricted mode"
                     16: and the CDPATH and MAIL* variables are implemented.
                     17: See also the BUGS section.
                     18: .LP
                     19: Features of the Korn shell are described in more detail.
                     20: Only a subset of the Korn shell features are currently implemented.
                     21: .SH DESCRIPTION
                     22: .SS Command syntax
                     23: The ``#'' character begins a one-line comment,
                     24: unless the ``#'' occurs inside a word.
                     25: The tokens ``;'', ``|'', ``&'', ``;;'', ``||'', ``&&'', ``('', and ``)''
                     26: stand by themselves.
                     27: A \fIword\fP is a sequence of any other non-whitespace characters,
                     28: which may also contain quoted strings
                     29: (quote character are ``\''', ``"'', ``\`'',
                     30: or a matching ``${ }'' or ``$( )'' pair).
                     31: A \fIname\fP is an unquoted word made up of letters, digits, or ``_''.
                     32: Any number of whitespace characters (space and tab) may separate words and tokens.
                     33: .LP
                     34: In the following syntax, { ... }? indicates an optional thing,
                     35: { ... }* indicates zero or more repetitions, { ... | ... } indicates alternatives.
                     36: .de S
                     37: .br
                     38: \\$1
                     39: .br
                     40: ..
                     41: .IP statement:
                     42: .S "\fB(\fP list \fB)\fP"
                     43: .S "\fB{\fP list \fB;\fP \fB}\fP"
                     44: .S "\fBfor\fP name { \fBin\fP { word }* }? \fBdo\fP list \fB;\fP \fBdone\fP"
                     45: .S "{ \fBwhile\fP | \fBuntil\fP } list \fB;\fP \fBdo\fP list \fB;\fP \fBdone\fP"
                     46: .S "\fBif\fP list \fB;\fP \fBthen\fP list \fB;\fP { \fBelif\fP list \fB;\fP \fBthen\fP list \fB;\fP }* { \fBelse\fP list \fB;\fP }?\fBfi\fP"
                     47: .S "\fBcase\fP name \fBin\fP { \fB(\fP word { \fB|\fP word } \fB)\fP list \fB;;\fP }* \fBesac\fP"
                     48: .S "\fBfunction\fP name \fB{\fP list \fB;\fP \fB}\fP"
                     49: .S "name \fB() {\fP list \fB;\fP \fB}\fP"
                     50: .S "\fBtime\fP pipe"
                     51: The opening parenthesis of the pattern is optional. 
                     52: Redirection may occur at the beginning or end of a statement.
                     53: .IP command:
                     54: .S "{ name=word }* { word }*"
                     55: Redirection may occur anywhere in a command.
                     56: .IP list:
                     57: .S "cond"
                     58: .S "cond \fB;\fP list"
                     59: .S "cond \fB&\fP list"
                     60: .IP cond:
                     61: .S "pipe"
                     62: .S "pipe \fB&&\fP cond"
                     63: .S "pipe \fB||\fP cond"
                     64: .IP pipe:
                     65: .S "statement { \fB|\fP statement }*"
                     66: .SS Alias expansion
                     67: Alias expansion occurs when the first word of a statement is a defined alias,
                     68: except when that alias is already being expanded.
                     69: It also occurs after the expansion of an alias whose definition ends with a space.
                     70: .SS Shell variables
                     71: The following standard special variables exist:
                     72: \fB!\fP, \fB#\fP, \fB$\fP, \fB\-\fP, \fB?\fP.
                     73: .IP CDPATH
                     74: Not yet implemented.
                     75: .IP ENV
                     76: If this variable is set at start-up
                     77: (after any profile files are executed),
                     78: the expanded value is used as shell start-up file.
                     79: It typically contains function and alias definitions.
                     80: .IP FCEDIT
                     81: The editor used by the \fIfc\fP command.
                     82: .IP IFS
                     83: \fIInternal field separator\fP,
                     84: used during substitution and the \fIread\fP command.
                     85: .IP HOME
                     86: The default directory for the \fIcd\fP command.
                     87: .IP "MAIL MAILCHECK MAILPATH"
                     88: Not yet implemented.
                     89: .IP PATH
                     90: The search path for executable commands and \fB.\fP'd files.
                     91: .IP "PS1 PS2"
                     92: \fBPS1\fP is the primary prompt for interactive shells.
                     93: Dollar substitution is performed, and \fB!\fP is replaced
                     94: with the command number (see \fIfc\fP).
                     95: .IP "PWD OLDPWD"
                     96: The current and previous working directories.
                     97: .IP SECONDS
                     98: The number of seconds since the shell was started.
                     99: .SS Substitution
                    100: In addition to the System Vr2 substitutions,
                    101: the following are available.
                    102: .IP "$(command)"
                    103: Like `command`, but no escapes are recognized.
                    104: .IP "$(<file)"
                    105: Equivalent to $(cat file), but without forking.
                    106: .IP "${#var}"
                    107: The length of the string value of \fIvar\fP,
                    108: or the number of arguments if \fIvar\fP is \fB*\fP or \fB@\fP.
                    109: .IP "${var#pattern} ${var##pattern}"
                    110: If \fIpattern\fP matches the beginning of the value of \fIvar\fP,
                    111: the matched text is deleted from the result of substitution.
                    112: A single \fB#\fP results in the shortest match,
                    113: two \fB#\fP's results in the longest match.
                    114: .IP "${var%pattern} ${var%%pattern}"
                    115: Like \fB#\fP substition, but deleting from the end of the value.
                    116: .SS Expressions
                    117: Expressions can be used with the \fBlet\fP command,
                    118: as numeric arguments to the \fBtest\fP command,
                    119: and as the value of an assignment to an integer variable.
                    120: .LP
                    121: Expression may contain alpha-numeric variable identifiers and integer constants
                    122: and may be combined with the following operators.
                    123: [list them]
                    124: .SS Command execution
                    125: After evaluation of keyword assignments and arguments,
                    126: the type of command is determined.
                    127: A command may execute a shell function, a shell built-in,
                    128: or an executable file.
                    129: .LP
                    130: Any keyword assignments are then performed according to
                    131: the type of command.
                    132: In function calls assignments are local to the function.
                    133: Assignments in built-in commands marked with a \(dg persist,
                    134: otherwise they are temporary.
                    135: Assignments in executable commands are exported to the sub-process
                    136: executing the command.
                    137: .LP
                    138: There are several built-in commands.
                    139: .IP ":"
                    140: Only expansion and assignment are performed.
                    141: This is the default if a command has no arguments.
                    142: .IP ". \fIfile\fP"
                    143: Execute the commands in \fIfile\fP without forking.
                    144: The file is searched in the directories of $PATH.
                    145: Passing arguments is not implemented.
                    146: .IP "alias [-d] [\fIname\fB=\fIvalue\fI ...]\fR"
                    147: Without arguments, \fBalias\fP lists all aliases and their values.
                    148: For any name without a value, its value is listed.
                    149: Any name with a value defines an alias, see "Alias Expansion" above.
                    150: Korn's tracked aliases are not implemented,
                    151: but System V command hashing is (see "hash").
                    152: .IP "bind [-m] [\fIkey_sequence=binding_name ...\fP]"
                    153: See section \fBInteractive Input Line Editing\fP for further details.
                    154: .IP "break [\fIlevels\fP]"
                    155: .IP "builtin \fIcommand arg ...\fP"
                    156: \fICommand\fP is executed as a built-in command.
                    157: .IP "cd [\fIpath\fP]"
                    158: Set the working directory to \fIpath\fP.
                    159: If \fIpath\fP is missing, the home directory ($HOME) is used.
                    160: If \fIpath\fP is \fB\-\fP, the previous working directory is used.
                    161: The PWD and OLDPWD variables are reset.
                    162: The System V two argument form is not implemented.
                    163: .IP "continue [\fIlevels\fP]"
                    164: .IP "echo ..."
                    165: \fIEcho\fP is replaced with the alias echo='print' in the Korn shell.
                    166: .IP "eval \fIcommand ...\fP"
                    167: .IP "exec \fIcommand arg ...\fP"
                    168: The executable command is executed without forking.
                    169: If no arguments are given, any IO redirection is permanent.
                    170: .IP "exit [\fIstatus\fP]"
                    171: .IP "fc [\fB\-l\fP] [\fB\-n\fP] [\fIfirst\fP [\fIlast\fP]]"
                    172: A simple subset of Korn's ``fix command''.
                    173: \fIFirst\fP and \fIlast\fP select commands.
                    174: Commands can be selected by history number,
                    175: or a string specifing the most recent command starting with that string.
                    176: The \fB\-l\fP option lists the command on stdout,
                    177: and \fB\-n\fP inhibits the default command numbers.
                    178: Without \fB\-l\fP, the selected commands can be edited by
                    179: the \fB$FCEDIT\fP editor, then executed by the shell.
                    180: .IP "\fBfc \-s\fP [\fIold\fB=\fInew\fR] [\fIcommand\fP]"
                    181: Re-execute the selected command (the previous command by default)
                    182: after performing the optional substitution of \fIold\fP with \fInew\fP.
                    183: This non-standard command is usually accessed with the predefined alias r="fc -s".
                    184: .IP "getopts"
                    185: See the attached manual page.
                    186: .IP "hash [\fB\-r\fP] [\fIname ...\fP]"
                    187: Without arguments, any hashed executable command pathnames are listed.
                    188: The \fB\-r\fP flag causes all hashed commands to be removed.
                    189: Each \fIname\fP is searched as if it where a command name
                    190: and added to the hash table if it is an executable command.
                    191: .IP "kill [-l] [\fB\-\fIsignal\fR] \fIprocess\fP ..."
                    192: Send a signal (TERM by default) to the named process.
                    193: The signal may be specified as a number or a mnemonic from <signal.h>
                    194: with the SIG prefix removed.
                    195: If option \fB-l\fP is specified, list all known signal types.
                    196: .IP "let [\fIexpression ...\fP]"
                    197: Each expression is evaluated, see "Expressions" above.
                    198: A zero status is returned if the last expression evaluates
                    199: to a non-zero value, otherwise a non-zero status is returned.
                    200: .IP "\fBprint\fP [\fB\-nreu\fIn\fR] [\fIargument ...\fP]"
                    201: \fBPrint\fP prints its arguments on the standard output,
                    202: separated by spaces, and terminated with a newline.
                    203: The \fB\-n\fP option eliminates the newline.
                    204: If option \fB-u\fIn\fR is specified, output is sent to shell
                    205: file descriptor \fIn\fP instead of \fIstdout\fR.
                    206: .PP
                    207: By default, certain C escapes are translated.
                    208: These include \eb, \ef, \en, \er, \et, \ev, and \e### (# is an octal digit).
                    209: \ec is equivalent to the \fB\-n\fP option.
                    210: This expansion may be inhibitted with the \fB\-r\fP option,
                    211: and may be re-enabled with the addition of the \fB\-e\fP option.
                    212: .IP "read [\fB\-ru\fIn\fR] \fIname ...\fP"
                    213: The first variable name may be of the form \fIname\fB?\fIprompt\fR.
                    214: .IP "readonly [\fIname ...\fP]"
                    215: .IP "return [\fIstatus\fP]"
                    216: .ta 5n 10n 30n
                    217: .de O
                    218: .br
                    219: \t\\$1\t\\$2\t\\$3
                    220: ..
                    221: .IP "set [\fB-\fP\fI[a-z]\fP] [\fB-o\fP \fIkeyword\fP] ..."
                    222: Set (\fB\-\fP) or clear (\fB+\fP) a shell option:
                    223: .O \-a allexport "all new variable are created with export attribute"
                    224: .O \-e errexit "exit on non-zero status [incorrect]"
                    225: .O "" bgnice "background jobs are run with lower priority"
                    226: .if \n(OE \{
                    227: .O "" emacs "BRL emacs-like line editing"\}
                    228: .O "" ignoreeof "shell will not exit of EOF, must use \fIexit\fP"
                    229: .O \-k keyword "variable assignments are recognized anywhere in command"
                    230: .O "" markdirs "[not implemented]"
                    231: .if \n(OJ \{
                    232: .O \-m monitor "job control enabled (default for interactive shell)"\}
                    233: .O \-n noexec "compile input but do not execute (ignored if interactive)"
                    234: .O \-f noglob "don't expand filenames"
                    235: .O \-u nounset "dollar expansion of unset variables is an error"
                    236: .O \-v verbose "echo shell commands on stdout when compiling"
                    237: .O \-h trackall "add command pathnames to hash table"
                    238: .O \-x xtrace "echo simple commands while executing"
                    239: .IP "set [\fB\-\-\fP] \fIarg ...\fP"
                    240: Set shell arguments.
                    241: .IP "shift [\fInumber\fP]"
                    242: .IP "test"
                    243: See the attached manual page.
                    244: .IP "times"
                    245: .IP "trap [\fIhandler\fP] [\fIsignal ...\fP]"
                    246: .IP "typeset [\fB\(+-irtx\fP] [\fIname\fP[\fB=\fIvalue\fR] ...]"
                    247: If no arguments are given, lists all variables and their attributes.
                    248: .PP
                    249: If options but no names are given, lists variables with specified
                    250: attributes, and their values if unless ``+'' is used.
                    251: .PP
                    252: If names are given, set the attributes of the named variables.
                    253: Variables may also be assigned a value.
                    254: If used inside a function, the created variable are local to the function.
                    255: .PP
                    256: The attributes are as follows.
                    257: .ta 5n 10n
                    258: \t\-i\tThe variable's value is stored as an integer.
                    259: .br
                    260: \t\-x\tThe variable is exported to the enviroment.
                    261: .br
                    262: \t\-r\tThe variable is read-only cannot be reassigned a value.
                    263: .br
                    264: \t\-t\tTrace (not implemented).
                    265: .br
                    266: \t\-f\tList functions instead of variable.
                    267: .IP "umask [\fIvalue\fP]"
                    268: .IP "unalias [-d] \fIname ...\fP"
                    269: The aliases for the given names are removed.
                    270: .IP "unset [\fB\-f\fP] \fIname ...\fP"
                    271: .IP "wait [\fIprocess-id\fP]"
                    272: .IP "whence [\fB\-v\fP] name ..."
                    273: For each name, the type of command is listed.
                    274: The \fB\-v\fP flag causes function and alias values to be listed.
                    275: .if \n(OJ \{.SS Job Control
                    276: Job control features are enabled by the
                    277: \fB\-m\fP or \fB\-o monitor\fP flags.
                    278: When job control is enabled,
                    279: background commands and foreground commands that have been stopped
                    280: (usually by a
                    281: .SM SIGTSTP
                    282: signal generated by typing
                    283: .IR ^Z\^ )
                    284: are placed into separate individual
                    285: .IR "process groups" .
                    286: The following commands are used to manipulate these process groups:
                    287: .PP
                    288: .PD 0
                    289: .TP "\w'\fBkill\fP \*(OK \fIjob\fP \*(CK\ \ \ 'u"
                    290: \fBjobs\fP
                    291: Display information about the controlled jobs.
                    292: The job number is given preceeded by a percent sign,
                    293: followed by a plus sign if it is the ``current job'',
                    294: or by a minus sign if it is the ``previous job'',
                    295: then the process group number for the job,
                    296: then the command.
                    297: .TP
                    298: kill [\fB\-\fIsignal\fR] \fIjob\fP ...
                    299: Send a signal (TERM by default) to the named job process group.
                    300: .TP
                    301: \fBfg\fP \*(OK \fIjob\fP \*(CK
                    302: Resume the stopped foreground job in the foreground.
                    303: If the process group
                    304: .I n
                    305: is not specified then the ``current job'' is resumed.
                    306: .TP
                    307: \fBbg\fP \*(OK \fIjob\fP \*(CK
                    308: Resume the stopped foreground job in the background.
                    309: If the process group
                    310: .I n
                    311: is not specified then the ``current job'' is resumed.
                    312: .PD
                    313: .PP
                    314: The \fBfg\fP, \fBbg\fP, \fBkill\fP, and \fBwait\fP commands
                    315: may refer to jobs with the following ``percent'' sequences.
                    316: The percent sign is optional with the fg and bg commands.
                    317: .PP
                    318: .PD 0
                    319: .TP "\w'\fBbg\fP \*(OK \fIn\fP \*(CK\ \ \ 'u"
                    320: .BR %+ ( %\- )
                    321: If there is a ``current job'' (``previous job''),
                    322: then that job is selected.
                    323: .TP
                    324: .BI % n
                    325: If the specified job number is one of the known jobs,
                    326: then that job is selected.
                    327: .TP
                    328: .BI % string
                    329: If the string matches the initial part of a job's command,
                    330: then that job is selected.
                    331: .TP
                    332: .BI %? string
                    333: As above, but the string may match any portion of the command.
                    334: .PD\}
                    335: .br
                    336: .if \n(OE \{.SS "Interactive Input Line Editing"
                    337: When the
                    338: .B emacs
                    339: option is set,
                    340: interactive input line editing is enabled.
                    341: This mode is slightly different from the emacs mode in AT&T's KornShell.
                    342: In this mode various
                    343: .I "editing commands"
                    344: (typically bound to one or more control characters)
                    345: cause immediate actions without waiting for a new-line.
                    346: Several
                    347: .I "editing commands"
                    348: are bound to particular control characters
                    349: when the shell is invoked;
                    350: these bindings can be changed using the following commands:
                    351: .br
                    352: .PP
                    353: .PD 0
                    354: .TP 2i
                    355: \fBbind\fP
                    356: The current bindings are listed.
                    357: .TP
                    358: \fBbind\fP \*(OK \fIstring\fP \*(CK = \*(OK \fIediting-command\fP \*(CK
                    359: The specified
                    360: .I "editing command\^"
                    361: is bound to the given
                    362: .IR string ,
                    363: which should consist of a control character
                    364: (which may be written using ``caret notation'' \fB^\fP\fIx\fP\|),
                    365: optionally preceded by one of the two prefix characters.
                    366: Future input of the
                    367: .I string
                    368: will cause the
                    369: .I "editing command\^"
                    370: to be immediately invoked.
                    371: .br
                    372: .TP
                    373: \fBbind -m\fP \*(OK \fIstring\fP \*(CK = \*(OK \fIsubstitute\fP \*(CK
                    374: The specified input
                    375: .I string
                    376: will afterwards be immediately replaced by the given
                    377: .I substitute
                    378: string,
                    379: which may contain
                    380: .IR "editing commands" .
                    381: .PD
                    382: .PP
                    383: The following
                    384: .I "editing commands"
                    385: are available;
                    386: first the command name is given
                    387: followed by its default binding (if any)
                    388: using caret notation
                    389: (note that the ASCII
                    390: .SM ESC
                    391: character is written as \s-1^[\s0\|),
                    392: then the editing function performed is decribed.
                    393: Note that
                    394: .I "editing command"
                    395: names are used only with the
                    396: .B bind
                    397: command.
                    398: Furthermore,
                    399: many
                    400: .I "editing commands"
                    401: are useful only on terminals with a visible cursor.
                    402: The default bindings were chosen to resemble corresponding EMACS key bindings.
                    403: .br
                    404: .PP
                    405: .PD 0
                    406: .TP "\w'\fBdelete-word-backward\ \ ^W\fP\ \ \ 'u"
                    407: \fBabort\ \ ^G\fP
                    408: Useful as a response to a request for a
                    409: .B search-history
                    410: pattern in order to abort the search.
                    411: .br
                    412: .TP
                    413: \fBauto-insert\fP
                    414: Simply causes the character to appear as literal input.
                    415: (Most ordinary characters are bound to this.)
                    416: .br
                    417: .TP
                    418: \fBbackward-char\ \ ^B\fP
                    419: Moves the cursor backward one character.
                    420: .br
                    421: .TP
                    422: \fBbackward-word\ \ ^[\|b\fP
                    423: Moves the cursor backward to the beginning of a word;
                    424: words are delimited by the current setting of \fB\s-1IFS\s0\fP.
                    425: .br
                    426: .TP
                    427: \fBbeginning-of-line\ \ ^A\fP
                    428: Moves the cursor to the beginning of the input line
                    429: (after the prompt string).
                    430: .br
                    431: .TP
                    432: \fBcomplete\ \ ^[\|^[\fP
                    433: Automatically completes as much as is unique of the hashed command name
                    434: or the file name containing the cursor.
                    435: If the entire remaining command or file name is unique
                    436: a space is printed after its completion,
                    437: unless it is a directory name in which case
                    438: .B /
                    439: is postpended.
                    440: If there is no hashed command or file name with the current partial word
                    441: as its prefix,
                    442: a bell character is output (usually causing a ``beep'').
                    443: .br
                    444: .TP
                    445: \fBcomplete-command\ \ ^X^[\fP
                    446: Automatically completes as much as is unique of the hashed command name
                    447: having the partial word up to the cursor as its prefix,
                    448: as in the
                    449: .B complete
                    450: command described above.
                    451: Only command and function names seen since the last
                    452: .B "hash \-r"
                    453: command are available for completion;
                    454: the
                    455: .B "hash"
                    456: command may be used to register additional names.
                    457: .br
                    458: .TP
                    459: \fBcomplete-file\ \ ^X\|^X\fP
                    460: Automatically completes as much as is unique of the file name
                    461: having the partial word up to the cursor as its prefix,
                    462: as in the
                    463: .B complete
                    464: command described above.
                    465: .br
                    466: .TP
                    467: \fBdelete-char-backward\ \ ^H\fP
                    468: Deletes the character before the cursor.
                    469: .br
                    470: .TP
                    471: \fBdelete-char-forward\ \ ^D\fP
                    472: Deletes the character after the cursor.
                    473: .br
                    474: .TP
                    475: \fBdelete-word-backward\ \ ^W\fP
                    476: Deletes characters before the cursor back to the beginning of a word.
                    477: .br
                    478: .TP
                    479: \fBdelete-word-forward\ \ ^[\|d\fP
                    480: Deletes characters after the cursor up to the end of a word.
                    481: .br
                    482: .TP
                    483: \fBdown-history\ \ ^N\fP
                    484: Scrolls the history buffer forward one line (later).
                    485: Each input line originally starts just after
                    486: the last entry in the history buffer,
                    487: so
                    488: .B down-history
                    489: is not useful until either
                    490: .B search-history
                    491: or
                    492: .B up-history
                    493: has been performed.
                    494: .br
                    495: .TP
                    496: \fBend-of-line\ \ ^E\fP
                    497: Moves the cursor to the end of the input line.
                    498: .br
                    499: .TP
                    500: \fBeot\ \ ^_\fP
                    501: Acts as an end-of-file;
                    502: this is useful because edit-mode input
                    503: disables normal terminal input canonicalization.
                    504: .br
                    505: .TP
                    506: \fBforward-char\ \ ^F\fP
                    507: Moves the cursor forward one position.
                    508: .br
                    509: .TP
                    510: \fBforward-word\ \ ^[\|f\fP
                    511: Moves the cursor forward to the end of a word.
                    512: .br
                    513: .TP
                    514: \fBkill-line\ \ ^U\fP
                    515: Deletes the entire input line.
                    516: .br
                    517: .TP
                    518: \fBkill-to-eol\ \ ^K\fP
                    519: Deletes the input from the cursor to the end of the line.
                    520: .br
                    521: .TP
                    522: \fBlist\ \ ^[\|?\fP
                    523: Prints a sorted, columnated list of hashed command names or file names
                    524: (if any) that can complete the partial word containing the cursor.
                    525: Directory names have
                    526: .B /
                    527: postpended to them,
                    528: and executable file names are followed by
                    529: .BR \(** .
                    530: .br
                    531: .TP
                    532: \fBlist-command\ \ ^X\|?\fP
                    533: Prints a sorted, columnated list of hashed command names
                    534: (if any) that can complete the partial word containing the cursor.
                    535: .br
                    536: .TP
                    537: \fBlist-file\fP
                    538: Prints a sorted, columnated list of file names
                    539: (if any) that can complete the partial word containing the cursor.
                    540: File type indicators are postpended as described under
                    541: .B list
                    542: above.
                    543: .br
                    544: .TP
                    545: \fBnewline\ \ ^J\ \fP\fIand\^\fP\fB\ ^M\fP
                    546: Causes the current input line to be processed by the shell.
                    547: (The current cursor position may be anywhere on the line.)
                    548: .br
                    549: .TP
                    550: \fBprefix-1\ \ ^[\fP
                    551: Introduces a 2-character command sequence.
                    552: .br
                    553: .TP
                    554: \fBprefix-2\ \ ^X\fP
                    555: Introduces a 2-character command sequence.
                    556: .br
                    557: .TP
                    558: \fBquote\ \ ^^\fP
                    559: The following character is taken literally
                    560: rather than as an
                    561: .IR "editing command" .
                    562: .br
                    563: .TP
                    564: \fBredraw\ \ ^L\fP
                    565: Reprints the prompt string and the current input line.
                    566: .br
                    567: .TP
                    568: \fBsearch-character\ \ ^]\fP
                    569: Search forward in the current line for the next keyboard character.
                    570: .br
                    571: .TP
                    572: \fBsearch-history\ \ ^R\fP
                    573: Enter incremental search mode.
                    574: The internal history list is searched backwards for commands matching the input.
                    575: An initial ``^'' in the search string anchors the search.
                    576: The escape key will leave search mode.
                    577: Other commands will be executed after leaving search mode.
                    578: Successive
                    579: .B search-history
                    580: commands continue searching backward
                    581: to the next previous occurrence of the pattern.
                    582: The history buffer retains only a finite number of lines;
                    583: the oldest are discarded as necessary.
                    584: .br
                    585: .ie \n(OX \{.TP
                    586: \fBstuff\ \ ^T\fP\}
                    587: .el \{.TP
                    588: \fBstuff\fP\}
                    589: On systems supporting it,
                    590: pushes the bound character back onto the terminal input
                    591: where it may receive special processing by the terminal handler.
                    592: .if \n(OX \{This is useful for the BRL
                    593: .B ^T
                    594: ``mini-systat'' feature,
                    595: for example.\}
                    596: .br
                    597: .TP
                    598: \fBstuff-reset\fP
                    599: Acts like
                    600: .BR stuff\^ ,
                    601: then aborts input the same as an interrupt.
                    602: .br
                    603: .ie \n(OX \{.TP
                    604: \fBtranspose-chars\fP\}
                    605: .el \{.TP
                    606: \fBtranspose-chars\ \ ^T\fP\}
                    607: Exchanges the two characters on either side of the cursor.
                    608: .br
                    609: .TP
                    610: \fBup-history\ \ ^P\fP
                    611: Scrolls the history buffer backward one line (earlier).
                    612: .br
                    613: .TP
                    614: \fByank\ \ ^Y\fP
                    615: Inserts the most recently killed text string at the current cursor position.
                    616: .br
                    617: .TP
                    618: \fByank-pop\ \ ^[\|y\fP
                    619: Immediately after a
                    620: .BR yank ,
                    621: replaces the inserted text string with the
                    622: next previous killed text string.
                    623: .PD\}
                    624: .br
                    625: .SH FILES
                    626: ~/.profile
                    627: .br
                    628: /etc/profile
                    629: .SH "SEE ALSO"
                    630: sh(1) on System V or Sun OS.
                    631: .LP
                    632: .I "UNIX Shell Programming,"
                    633: Stephan G. Kochan,
                    634: Patrick H. Wood,
                    635: Hayden.
                    636: .LP
                    637: .I "KornShell: Command and Programming Language (not yet published),"
                    638: Morris Bolsky and David Korn.
                    639: .SH AUTHORS
                    640: Based on the public domain 7th edition Bourne shell.
                    641: .LP
                    642: System V and Korn modifications by Eric Gisin,
                    643: with contributions by
                    644: Ron Natalie, Arnold Robbins, Doug Gwyn, Erik Baalbergen, AT&T.\" getopt(3)
                    645: .SH "DIFFERENCES FROM AT&T VERSION"
                    646: Vi editing mode is not implemented.
                    647: The \fBselect\fP statement is not implemented.
                    648: "\fBfc \-e \-\fP" is not implemented, use "\fBfc \-s\fP".
                    649: The variables \fBRANDOM\fP and \fBPPID\fP are not implemented.
                    650: Variable arrays are not implemented.
                    651: Variable attributes other than integer are not implemented.
                    652: The \fBERR\fP and \fBEXIT\fP traps are not implemented for functions.
                    653: Alias expansion is inhibited at the beginning of an alias definition
                    654: in the AT&T version.
                    655: .SH BUGS
                    656: Interactive shells will occasionally hang while waiting for a job.
                    657: .LP
                    658: The 8th bit is stripped in emacs mode.
                    659: .LP
                    660: Please report any other bugs by mail to [email protected] or [email protected].
                    661: .TH TEST 1 "January 1988" "Korn shell"
                    662: .ta 30n
                    663: .de X
                    664: .br
                    665: \\$1\t\\$2
                    666: ..
                    667: .SH NAME
                    668: test \- test condition (Korn and 8th edition)
                    669: .SH SYNOPSIS
                    670: \fBtest\fP \fIexpression\fP
                    671: .br
                    672: \fB[\fP \fIexpression\fP \fB]\fP
                    673: .SH DESCRIPTION
                    674: \fBTest\f evalutates the \fIexpression\fP and returns zero status if true,
                    675: and non-zero status otherwise.
                    676: It is normally used as the controlling command of the \fBif\fP and \fBwhile\fP statements.
                    677: .LP
                    678: The following basic expressions are available.
                    679: .IP
                    680: .X "-r file" "file exists and is readable"
                    681: .X "-w file" "file exists and is writable"
                    682: .X "-x file" "file exists and is executable"
                    683: .X "-f file" "file is a regular file"
                    684: .X "-d file" "file is a directory"
                    685: .X "-c file" "file is a character special device"
                    686: .X "-b file" "file is a block special device"
                    687: .X "-p file" "file is a named pipe"
                    688: .X "-u file" "file mode has setuid bit"
                    689: .X "-g file" "file mode has setgid bit"
                    690: .X "-k file" "file mode has sticky bit"
                    691: .X "-s file" "file is not empty"
                    692: .X "-L file" "file is a symbolic link"
                    693: .X "-S file" "file is a socket"
                    694: .X "file -nt file" "first file is newer than second file"
                    695: .X "file -ot file" "first file is older than second file"
                    696: .X "file -ef file" "first file is the same file as second file"
                    697: .X "-t filedes" "file descriptor is a tty device"
                    698: .IP
                    699: .X "string" "string is not null"
                    700: .X "-z string" "string is null"
                    701: .X "-n string" "string is not null"
                    702: .X "string = string" "strings are equal"
                    703: .X "string != string" "strings are not equal"
                    704: .IP
                    705: .X "number -eq number" "numbers compare equal"
                    706: .X "number -ne number" "numbers compare not equal"
                    707: .X "number -ge number" "numbers compare greater than or equal"
                    708: .X "number -gt number" "numbers compare greater than"
                    709: .X "number -le number" "numbers compare less than or equal"
                    710: .X "number -lt number" "numbers compare less than"
                    711: .LP
                    712: The above basic expressions may be combined with the following operators.
                    713: .IP
                    714: .X "expr -o expr" "logical or"
                    715: .X "expr -a expr" "logical and"
                    716: .X "! expr" "logical not"
                    717: .X "( expr )" "grouping"
                    718: .SH AUTHOR
                    719: Erik Baalbergen. Modified by Arnold Robbins.
                    720: .rn LP P
                    721: .TH GETOPTS 1 "January 1988" "Korn shell"
                    722: .SH NAME
                    723: getopts \- parse command options
                    724: .SH SYNOPSIS
                    725: .B getopts
                    726: optstring name [arg ...]
                    727: .SH DESCRIPTION
                    728: .I getopts
                    729: is used by shell procedures
                    730: to parse positional parameters and to check for legal options.
                    731: It supports all applicable rules of the command syntax standard
                    732: (see Rules 3-10,
                    733: .IR intro (1)).
                    734: It should be used in place of the
                    735: .IR getopt (1)
                    736: command.
                    737: (See the
                    738: .BR \s-1WARNING\s0 ,
                    739: below.)
                    740: .PP
                    741: .I optstring
                    742: must contain the option letters the command using
                    743: .I getopts
                    744: will recognize;
                    745: if a letter is followed by a colon,
                    746: the option is expected to have an argument
                    747: which should be separated from it by white space.
                    748: .PP
                    749: Each time it is invoked,
                    750: .I getopts
                    751: will place the next option in the shell variable
                    752: .I name
                    753: and the index of the next argument to be processed in the shell variable
                    754: .BR \s-1OPTIND\s0 .
                    755: Whenever the shell or a shell procedure is invoked,
                    756: .B \s-1OPTIND\s0
                    757: is initialized to
                    758: .BR 1 .
                    759: .PP
                    760: When an option requires an option-argument,
                    761: .I getopts
                    762: places it in the shell variable
                    763: .BR \s-1OPTARG\s0 .
                    764: .P
                    765: If an illegal option is encountered,
                    766: .B ?\&
                    767: will be placed in
                    768: .IR name .
                    769: .P
                    770: When the end of the options is encountered,
                    771: .I getopts
                    772: exits with a non-zero exit status.
                    773: The special option
                    774: .RB `` \-\- ''
                    775: may be used to delimit the end of the options.
                    776: .P
                    777: By default,
                    778: .I getopts
                    779: parses the positional parameters.
                    780: If extra arguments
                    781: .RI ( arg
                    782: \&...) are given on the
                    783: .I getopts
                    784: command line,
                    785: .I getopts
                    786: will parse them instead.
                    787: .PP
                    788: So all new commands will adhere to the command syntax standard described in
                    789: .IR intro (1),
                    790: they should use
                    791: .IR getopts (1)
                    792: or
                    793: .IR getopt (3C)
                    794: to parse positional parameters
                    795: and check for options that are legal for that command
                    796: (see
                    797: .BR \s-1WARNINGS\s0 ,
                    798: below).
                    799: .SH EXAMPLE
                    800: The following fragment of a shell program
                    801: shows how one might process the arguments
                    802: for a command that can take the options
                    803: .B a
                    804: or
                    805: .BR b ,
                    806: as well as the option
                    807: .BR o ,
                    808: which requires an option-argument:
                    809: .PP
                    810: .RS
                    811: .nf
                    812: .ss 18
                    813: .ta +.5i +1i
                    814: \fBwhile getopts abo: c
                    815: do
                    816:        case $c in
                    817:        a\(bvb) FLAGS=$FLAGS$c;;
                    818:        o)      OARG=$OPTARG;;
                    819:        \e?)    echo $USAGE 1>&2
                    820:                exit 2;;
                    821:        esac
                    822: done
                    823: shift OPTIND\-1\fP
                    824: .fi
                    825: .ta
                    826: .ss 12
                    827: .RE
                    828: .PP
                    829: This code will accept any of the following as equivalent:
                    830: .PP
                    831: .RS
                    832: .nf
                    833: .ss 18
                    834: \fBcmd \-a \-b \-o "xxx z yy" file
                    835: cmd \-a \-b \-o "xxx z yy" \-\- file
                    836: cmd \-ab \-o "xxx z yy" file
                    837: cmd \-ab \-o "xxx z yy" \-\- file\fP
                    838: .fi
                    839: .ss 12
                    840: .RE
                    841: .SH SEE ALSO
                    842: intro(1),
                    843: sh(1).
                    844: .br
                    845: getopt(3C)
                    846: in the
                    847: .IR "Programmer's Reference Manual" .
                    848: .br
                    849: .IR "UNIX System V Release 3.0 Release Notes" .
                    850: .SH WARNING
                    851: Although the following command syntax rule (see
                    852: .IR intro (1))
                    853: relaxations are permitted under the current implementation,
                    854: they should not be used because they may not be supported
                    855: in future releases of the system.
                    856: As in the
                    857: .B \s-1EXAMPLE\s0
                    858: section above,
                    859: .B a
                    860: and
                    861: .B b
                    862: are options,
                    863: and the option
                    864: .B o
                    865: requires an option-argument:
                    866: .PP
                    867: .RS
                    868: .nf
                    869: .ta +1i +1.5i
                    870: \fBcmd \-aboxxx file\fP        (Rule 5 violation: options with
                    871:        option-arguments must not be grouped with other options)
                    872: \fBcmd \-ab \-oxxx file\fP     (Rule 6 violation: there must be
                    873:        white space after an option that takes an option-argument)
                    874: .fi
                    875: .ta
                    876: .RE
                    877: .PP
                    878: Changing the value of the shell variable
                    879: .B \s-1OPTIND\s0
                    880: or parsing different sets of arguments
                    881: may lead to unexpected results.
                    882: .SH DIAGNOSTICS
                    883: .I getopts
                    884: prints an error message on the standard error output
                    885: when it encounters an option letter not included in
                    886: .IR optstring .

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.