Annotation of researchv10dc/man/manb/osh.1, revision 1.1.1.1

1.1       root        1: .if t .ds ' \[email protected]@\s+4\[email protected]@\'\[email protected]@\s-4\[email protected]@
                      2: .if n .ds ' '
                      3: .if t .ds ` \[email protected]@\s+4\[email protected]@\`\[email protected]@\s-4\[email protected]@
                      4: .if n .ds ` `
                      5: .ds OK [\|
                      6: .ds CK \|]
                      7: .TH SH 1
                      8: .SH NAME
                      9: sh \- shell, the standard command programming language
                     10: .SH SYNOPSIS
                     11: .B sh
                     12: [
                     13: .B \-ceiknrstuvx
                     14: ] [ args ]
                     15: .SH DESCRIPTION
                     16: .I Sh\^
                     17: is a command programming language
                     18: that executes commands read from a terminal
                     19: or a file.
                     20: See
                     21: .I Invocation\^
                     22: below
                     23: for the meaning of arguments to the shell.
                     24: .SS Commands.
                     25: A
                     26: .I simple-command\^
                     27: is a sequence of non-blank
                     28: .I words\^
                     29: separated by
                     30: .I blanks\^
                     31: (a
                     32: .I blank\^
                     33: is a
                     34: tab
                     35: or a
                     36: space).
                     37: The first word specifies the name of the command to
                     38: be executed.
                     39: Except as specified below,
                     40: the remaining words are passed as arguments
                     41: to the invoked command.
                     42: The command name is passed as argument 0
                     43: (see
                     44: .IR exec (2)).
                     45: The
                     46: .I value\^
                     47: of a simple-command is its exit status
                     48: if it terminates normally, or (octal) 200+\f2status\^\fP if
                     49: it terminates abnormally (see
                     50: .IR signal (2)
                     51: for a list of
                     52: status values).
                     53: .PP
                     54: A
                     55: .I pipeline\^
                     56: is a sequence of one or more
                     57: .I commands\^
                     58: separated by
                     59: .BR \(bv .
                     60: The standard output of each command but the last
                     61: is connected by a
                     62: .IR pipe (2)
                     63: to the standard input of the next command.
                     64: Each command is run as a separate process;
                     65: the shell waits for the last command to terminate.
                     66: .PP
                     67: A
                     68: .I list\^
                     69: is a sequence of one or more
                     70: pipelines
                     71: separated by
                     72: .BR ; ,
                     73: .BR & ,
                     74: .BR && ,
                     75: or
                     76: .BR \(bv\|\(bv ,
                     77: and optionally terminated by
                     78: .B ;
                     79: or
                     80: .BR & .
                     81: Of these four symbols,
                     82: .B ;
                     83: and
                     84: .B &
                     85: have equal precedence,
                     86: which is lower than that of
                     87: .B &&
                     88: and
                     89: .BR \(bv\|\(bv .
                     90: The symbols
                     91: .B &&
                     92: and
                     93: .B \(bv\|\(bv
                     94: also have equal precedence.
                     95: A semicolon
                     96: .RB ( ; )
                     97: causes sequential execution of the preceding pipeline; an ampersand
                     98: .RB ( & )
                     99: causes asynchronous execution of the preceding pipeline (i.e., the shell does
                    100: .I not\^
                    101: wait for that pipeline to finish).
                    102: The symbol
                    103: .B &&
                    104: .RB (\| \(bv\|\(bv \^)
                    105: causes the
                    106: .I list\^
                    107: following it to be executed only if the preceding
                    108: pipeline
                    109: returns a zero (non-zero) exit status.
                    110: An arbitrary number of new-lines may appear in a
                    111: .IR list ,
                    112: instead of semicolons,
                    113: to delimit commands.
                    114: .PP
                    115: A
                    116: .I command\^
                    117: is either a simple-command
                    118: or one of the following.
                    119: Unless otherwise stated,
                    120: the value returned by a command is that of the
                    121: last simple-command executed in the command.
                    122: .PP
                    123: .PD 0
                    124: .TP
                    125: \f3for\fP \f2name\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3do\fP \f2list\^\fP \f3done\fP
                    126: Each time a
                    127: .B for
                    128: command is executed,
                    129: .I name\^
                    130: is set to the next
                    131: .I word\^
                    132: taken from the
                    133: .B in
                    134: .I word\^
                    135: list.
                    136: If
                    137: .BI in " word\^"
                    138: \&.\|.\|.
                    139: is omitted, then
                    140: the
                    141: .B for
                    142: command executes the \f3do\fP \f2list\^\fP once for each positional parameter
                    143: that is set
                    144: (see
                    145: .I "Parameter Substitution\^"
                    146: below).
                    147: Execution ends when there are no more words in the list.
                    148: .TP
                    149: \f3case\fP \f2word\^\fP \f3in\fP \*(OK \f2pattern\^\fP \*(OK \(bv \
                    150: \f2pattern\^\fP \*(CK .\|.\|. \f3)\fP \f2list\^\fP \f3;;\fP \*(CK .\|.\|. \f3esac\fP
                    151: A
                    152: .B case
                    153: command executes the
                    154: .I list\^
                    155: associated with the first
                    156: .I pattern\^
                    157: that matches
                    158: .IR word .
                    159: The form of the patterns is
                    160: the same as that used for
                    161: file-name generation (see 
                    162: .I "File Name Generation\^"
                    163: below).
                    164: .TP
                    165: \f3if\fP \f2list\^\fP \f3then\fP \f2list\^\fP \*(OK \
                    166: \f3elif\fP \f2list\^\fP \f3then\fP \f2list\^\fP \*(CK .\|.\|. \
                    167: \*(OK \f3else\fP \f2list\^\fP \*(CK \f3f\&i\fP
                    168: The
                    169: .I list\^
                    170: following \f3if\fP is executed and,
                    171: if it
                    172: returns a zero exit status, the
                    173: .I list\^
                    174: following
                    175: the first
                    176: .B then
                    177: is executed.
                    178: Otherwise, the
                    179: .I list\^
                    180: following \f3elif\fP
                    181: is executed and, if its value is zero,
                    182: the
                    183: .I list\^
                    184: following
                    185: the next
                    186: .B then
                    187: is executed.
                    188: Failing that, the
                    189: .B else
                    190: .I list\^
                    191: is executed.
                    192: If no
                    193: .B else
                    194: .I list\^
                    195: or
                    196: .B then
                    197: .I list\^
                    198: is executed, then the
                    199: .B if
                    200: command returns a zero exit status.
                    201: .TP
                    202: \f3while\fP \f2list\^\fP \f3do\fP \f2list\^\fP \f3done\fP
                    203: A
                    204: .B while
                    205: command repeatedly executes the
                    206: .B while
                    207: .I list\^
                    208: and, if the exit status of the last command in the list is zero, executes
                    209: the
                    210: .B do
                    211: .IR list ;
                    212: otherwise the loop terminates.
                    213: If no commands in the
                    214: .B do
                    215: .I list\^
                    216: are executed, then the
                    217: .B while
                    218: command returns a zero exit status;
                    219: .B until
                    220: may be used in place of
                    221: .B while
                    222: to negate
                    223: the loop termination test.
                    224: .TP
                    225: \f3(\fP\f2list\^\fP\f3)\fP
                    226: .br
                    227: Execute
                    228: .I list\^
                    229: in a sub-shell.
                    230: .TP
                    231: \f3{\fP\f2list\^\fP\f3;}\fP
                    232: .br
                    233: .I list\^
                    234: is simply executed.
                    235: .PD
                    236: .PP
                    237: The following words
                    238: are only recognized as the first word of a command
                    239: and when not quoted:
                    240: .if t .RS
                    241: .PP
                    242: .B
                    243: .if n if then else elif fi case esac for while until do done { }
                    244: .if t if  then  else  elif  f\&i  case  esac  for  while  until  do  done  {  }
                    245: .if t .RE
                    246: .SS Comments.
                    247: A word beginning with
                    248: .B #
                    249: causes that word and all the following characters up to a new-line
                    250: to be ignored.
                    251: .SS Command Substitution.
                    252: The standard output from a command enclosed in
                    253: a pair of grave accents (\^\f3\*`\^\*`\fP\^) may be used as part or all
                    254: of a word;
                    255: trailing new-lines are removed.
                    256: .SS Parameter Substitution.
                    257: The character
                    258: .B $
                    259: is used to introduce substitutable
                    260: .IR parameters .
                    261: Positional parameters may be assigned values by
                    262: .BR set .
                    263: Variables may be set by writing:
                    264: .RS
                    265: .PP
                    266: .IB name = value\^
                    267: \*(OK
                    268: .IB name = value\^
                    269: \*(CK .\|.\|.
                    270: .RE
                    271: .PP
                    272: Pattern-matching is not performed on
                    273: .IR value .
                    274: .PP
                    275: .PD 0
                    276: .TP
                    277: \f3${\fP\f2parameter\^\fP\f3}\fP
                    278: A
                    279: .I parameter\^
                    280: is a sequence of letters, digits, or underscores (a
                    281: .IR name ),
                    282: a digit,
                    283: or any of the characters
                    284: .BR \(** ,
                    285: .BR @ ,
                    286: .BR # ,
                    287: .BR ? ,
                    288: .BR \- ,
                    289: .BR $ ,
                    290: and
                    291: .BR !\\^ .
                    292: The value, if any, of the parameter is substituted.
                    293: The braces are required only when
                    294: .I parameter\^
                    295: is followed by a letter, digit, or underscore
                    296: that is not to be interpreted as part of its name.
                    297: A
                    298: .I name\^
                    299: must begin with a letter or underscore.
                    300: If
                    301: .I parameter\^
                    302: is a digit then it is a positional parameter.
                    303: If
                    304: .I parameter\^
                    305: is
                    306: .B \(**
                    307: or
                    308: .BR @ ,
                    309: then all the positional
                    310: parameters, starting with
                    311: .BR $1 ,
                    312: are substituted
                    313: (separated by spaces).
                    314: Parameter
                    315: .B $0
                    316: is set from argument zero when the shell
                    317: is invoked.
                    318: .TP
                    319: \f3${\fP\f2parameter\^\fP\f3:\-\fP\f2word\^\fP\f3}\fP
                    320: If
                    321: .I parameter\^
                    322: is set and is non-null then substitute its value;
                    323: otherwise substitute
                    324: .IR word .
                    325: .TP
                    326: \f3${\fP\f2parameter\^\fP\f3:=\fP\f2word\^\fP\f3}\fP
                    327: If
                    328: .I parameter\^
                    329: is not set or is null
                    330: then set it to
                    331: .IR word ;
                    332: the value of the parameter is then substituted.
                    333: Positional parameters may not be assigned to
                    334: in this way.
                    335: .TP
                    336: \f3${\fP\f2parameter\^\fP\f3:?\fP\f2word\^\fP\f3}\fP
                    337: If
                    338: .I parameter\^
                    339: is set and is non-null then substitute its value;
                    340: otherwise, print
                    341: .I word\^
                    342: and exit from the shell.
                    343: If
                    344: .I word\^
                    345: is omitted, then the message
                    346: ``parameter null or not set''
                    347: is printed.
                    348: .TP
                    349: \f3${\fP\f2parameter\^\fP\f3:+\fP\f2word\^\fP\f3}\fP
                    350: If
                    351: .I parameter\^
                    352: is set and is non-null then substitute
                    353: .IR word ;
                    354: otherwise substitute nothing.
                    355: .PD
                    356: .PP
                    357: In the above,
                    358: .I word\^
                    359: is not evaluated unless it is
                    360: to be used as the substituted string,
                    361: so that, in the following example,
                    362: .B pwd
                    363: is executed only if
                    364: .B d
                    365: is not set or is null:
                    366: .RS
                    367: .PP
                    368: echo \|${d:\-\^\*`\^pwd\^\*`\^}
                    369: .RE
                    370: .PP
                    371: If the colon
                    372: .RB ( : )
                    373: is omitted from the above expressions, then the
                    374: shell only checks whether 
                    375: .I parameter\^
                    376: is set or not.
                    377: .PP
                    378: The following
                    379: parameters
                    380: are automatically set by the shell:
                    381: .RS
                    382: .PD 0
                    383: .TP
                    384: .B #
                    385: The number of positional parameters in decimal.
                    386: .TP
                    387: .B \-
                    388: Flags supplied to the shell on invocation or by
                    389: the
                    390: .B set
                    391: command.
                    392: .TP
                    393: .B ?
                    394: The decimal value returned by the last synchronously executed command.
                    395: .TP
                    396: .B $
                    397: The process number of this shell.
                    398: .TP
                    399: .B !
                    400: The process number of the last background command invoked.
                    401: .PD
                    402: .RE
                    403: .PP
                    404: The following
                    405: parameters
                    406: are used by the shell:
                    407: .RS
                    408: .PD 0
                    409: .TP
                    410: .B
                    411: .SM HOME
                    412: The default argument (home directory) for the
                    413: .I cd\^
                    414: command.
                    415: .TP
                    416: .B
                    417: .SM PATH
                    418: The search path for commands (see
                    419: .I Execution\^
                    420: below).
                    421: .TP
                    422: .B
                    423: .SM MAIL
                    424: If this variable is set to the name of
                    425: a mail file, then the shell informs the user of
                    426: the arrival of mail in the specified file.
                    427: .TP
                    428: .SM
                    429: .B PS1
                    430: Primary prompt string, by default
                    431: .RB `` "$ \|" ''.
                    432: .TP
                    433: .SM
                    434: .B PS2
                    435: Secondary prompt string, by default
                    436: .RB `` "> \|" ''.
                    437: .TP
                    438: .SM
                    439: .B IFS
                    440: Internal field separators,
                    441: normally
                    442: .BR space ,
                    443: .BR tab ,
                    444: and
                    445: .BR new-line .
                    446: .PD
                    447: .RE
                    448: .PP
                    449: The shell gives default values to
                    450: \f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP, \f3\s-1PS2\s+1\fP, and \f3\s-1IFS\s+1\fP,
                    451: while
                    452: .SM
                    453: .B HOME
                    454: and
                    455: .SM
                    456: .B MAIL
                    457: are
                    458: not set at all by the shell (although
                    459: .SM
                    460: .B HOME
                    461: .I is\^
                    462: set by
                    463: .IR login (1)).
                    464: .SS Blank Interpretation.
                    465: After parameter and command substitution,
                    466: the results of substitution are scanned for internal field separator
                    467: characters (those found in
                    468: .BR \s-1IFS\s+1 )
                    469: and split into distinct arguments where such characters are found.
                    470: Explicit null arguments (\^\f3"\^"\fP or \f3\*'\^\*'\fP\^) are retained.
                    471: Implicit null arguments
                    472: (those resulting from
                    473: .I parameters\^
                    474: that have no values) are removed.
                    475: .SS File Name Generation.
                    476: Following substitution, each command
                    477: .I word\^
                    478: is scanned for
                    479: the characters
                    480: .BR \(** ,
                    481: .BR ? ,
                    482: and
                    483: .BR \*(OK .
                    484: If one of these characters appears
                    485: then the word is regarded as a
                    486: .IR pattern .
                    487: The word is replaced with alphabetically sorted file names that match the pattern.
                    488: If no file name is found that matches the pattern, then
                    489: the word is left unchanged.
                    490: The character
                    491: .B .
                    492: at the start of a file name
                    493: or immediately following a
                    494: .BR / ,
                    495: as well as the character
                    496: .B /
                    497: itself,
                    498: must be matched explicitly.
                    499: .PP
                    500: .PD 0
                    501: .RS
                    502: .TP
                    503: .B \(**
                    504: Matches any string, including the null string.
                    505: .TP
                    506: .B ?
                    507: Matches any single character.
                    508: .TP
                    509: .BR \*(OK .\|.\|.\^ \*(CK
                    510: Matches any one of the enclosed characters.
                    511: A pair of characters separated by
                    512: .B \-
                    513: matches any
                    514: character lexically between the pair, inclusive.
                    515: If the first character following the opening 
                    516: \`\`\*(OK\'\'
                    517: is a
                    518: .B "``!''"
                    519: then any character not enclosed is matched.
                    520: .PD
                    521: .RE
                    522: .SS Quoting.
                    523: The following characters have a special meaning to the shell
                    524: and cause termination of a word unless quoted:
                    525: .RS
                    526: .PP
                    527: \f3;  &  (  )  \(bv  <  >  new-line  space  tab\fP
                    528: .RE
                    529: .PP
                    530: A character may be
                    531: .I quoted\^
                    532: (i.e., made to stand for itself)
                    533: by preceding
                    534: it with a
                    535: .BR \e .
                    536: The pair
                    537: .B \enew-line
                    538: is ignored.
                    539: All characters enclosed between a pair of single quote marks (\^\f3\*'\^\*'\fP\^),
                    540: except a single quote,
                    541: are quoted.
                    542: Inside double quote marks
                    543: (\f3"\^"\fP),
                    544: parameter and command substitution occurs and
                    545: .B \e
                    546: quotes the characters
                    547: .BR \e ,
                    548: .BR \*` ,
                    549: \f3"\fP,
                    550: and
                    551: .BR $ .
                    552: .B
                    553: "$\(**"
                    554: is equivalent to
                    555: \f3"$1 \|$2\fP \|.\|.\|.\f3"\fP,
                    556: whereas
                    557: .B
                    558: "$@"
                    559: is equivalent to
                    560: .B
                    561: "$1"\|
                    562: .B
                    563: "$2"\|
                    564: \&.\|.\|.\|.
                    565: .SS Prompting.
                    566: When used interactively,
                    567: the shell prompts with the value of
                    568: .SM
                    569: .B PS1
                    570: before reading a command.
                    571: If at any time a new-line is typed and further input is needed
                    572: to complete a command, then the secondary prompt
                    573: (i.e., the value of
                    574: .BR \s-1PS2\s+1 )
                    575: is issued.
                    576: .SS Input/Output.
                    577: Before a command is executed, its input and output
                    578: may be redirected using a special notation interpreted by the shell.
                    579: The following may appear anywhere in a simple-command
                    580: or may precede or follow a
                    581: .I command\^
                    582: and are
                    583: .I not\^
                    584: passed on to the invoked command;
                    585: substitution occurs before
                    586: .I word\^
                    587: or
                    588: .I digit\^
                    589: is used:
                    590: .PP
                    591: .PD 0
                    592: .TP 14
                    593: .B <word
                    594: Use file
                    595: .I word\^
                    596: as standard input (file descriptor 0).
                    597: .TP
                    598: .B >word
                    599: Use file
                    600: .I word\^
                    601: as standard output (file descriptor 1).
                    602: If the file does not exist then it is created;
                    603: otherwise, it is truncated to zero length.
                    604: .TP
                    605: .B >\[email protected]@>word
                    606: Use file
                    607: .I word\^
                    608: as standard output.
                    609: If the file exists then output is appended to it (by first seeking to the end-of-file);
                    610: otherwise, the file is created.
                    611: .TP
                    612: \f3<\[email protected]@<\fP\*(OK\f3\-\fP\*(CK\f3word\fP
                    613: The shell input is read up to a line that is the same as
                    614: .IR word ,
                    615: or to an end-of-file.
                    616: The resulting document becomes
                    617: the standard input.
                    618: If any character of
                    619: .I word\^
                    620: is quoted, then no interpretation
                    621: is placed upon the characters of the document;
                    622: otherwise, parameter and command substitution occurs,
                    623: (unescaped)
                    624: .B \enew-line
                    625: is ignored,
                    626: and
                    627: .B \e
                    628: must be used to quote the characters
                    629: .BR \e ,
                    630: .BR $ ,
                    631: .BR \*` ,
                    632: and the first character of
                    633: .IR word .
                    634: If
                    635: .B \-
                    636: is appended to
                    637: .BR <\[email protected]@< ,
                    638: then all leading tabs are stripped from
                    639: .I word\^
                    640: and from the document.
                    641: .TP
                    642: .B <&digit
                    643: The standard input is duplicated from file descriptor
                    644: .I digit\^
                    645: (see
                    646: .IR dup (2)).
                    647: Similarly for the standard output using
                    648: .BR > .
                    649: .TP
                    650: .B <&\-
                    651: The standard input is closed.
                    652: Similarly for the standard output using
                    653: .BR > .
                    654: .PD
                    655: .PP
                    656: If one of the above is preceded by a digit,
                    657: then the
                    658: file descriptor created is that specified
                    659: by the digit
                    660: (instead of the default 0 or 1).
                    661: For example:
                    662: .RS
                    663: .PP
                    664: \&.\|.\|. \|2>&1
                    665: .RE
                    666: .PP
                    667: creates file descriptor 2 that is a duplicate
                    668: of file descriptor 1.
                    669: .PP
                    670: If a command is followed by
                    671: .B &
                    672: then the default standard input
                    673: for the command
                    674: is the empty file
                    675: .BR /dev/null .
                    676: Otherwise, the environment for the execution of a command contains the
                    677: file descriptors of the invoking shell as modified by
                    678: input/output specifications.
                    679: .SS Environment.
                    680: The
                    681: .I environment\^
                    682: (see
                    683: .IR environ (7))
                    684: is a list of name-value pairs that is passed to
                    685: an executed program in the same way as a normal argument list.
                    686: The shell interacts with the environment in several ways.
                    687: On invocation, the shell scans the environment
                    688: and creates a
                    689: parameter
                    690: for each name found,
                    691: giving it the corresponding value.
                    692: Executed commands inherit the same environment.
                    693: If the user modifies the values of these
                    694: parameters
                    695: or creates new ones,
                    696: none of these affects the environment
                    697: unless the
                    698: .B export
                    699: command is used to bind the shell's
                    700: parameter
                    701: to the environment.
                    702: The environment seen by any executed command is thus composed
                    703: of any unmodified name-value pairs originally inherited by the shell,
                    704: plus any modifications or additions,
                    705: all of which must be noted in
                    706: .B export
                    707: commands.
                    708: .PP
                    709: The environment for any
                    710: .I simple-command\^
                    711: may be augmented by prefixing it with one or more assignments to
                    712: parameters.
                    713: Thus:
                    714: .RS
                    715: .PP
                    716: \s-1TERM\s+1=450 \|cmd \|args                          and
                    717: .br
                    718: (export \|\s-1TERM\s+1; \|\s-1TERM\s+1=450; \|cmd \|args)
                    719: .RE
                    720: .PP
                    721: are equivalent (as far as the above execution of
                    722: .I cmd\^
                    723: is concerned).
                    724: .PP
                    725: If the
                    726: .B \-k
                    727: flag is set,
                    728: .I all\^
                    729: keyword arguments are placed in the environment,
                    730: even if they occur after the command name.
                    731: The following
                    732: first prints
                    733: .B "a=b c"
                    734: and then
                    735: .BR c:
                    736: .PP
                    737: .RS
                    738: .nf
                    739: echo \|a=b \|c
                    740: set \|\-k
                    741: echo \|a=b \|c
                    742: .fi
                    743: .RE
                    744: .SS Signals.
                    745: The \s-1INTERRUPT\s+1 and \s-1QUIT\s+1 signals for an invoked
                    746: command are ignored if the command is followed by
                    747: .BR & ;
                    748: otherwise signals have the values
                    749: inherited by the shell from its parent,
                    750: with the exception of signal 11
                    751: (but see also
                    752: the
                    753: .B trap
                    754: command below).
                    755: .SS Execution.
                    756: Each time a command is executed, the above substitutions
                    757: are carried out.
                    758: Except for the
                    759: .I "Special Commands\^"
                    760: listed below, a new
                    761: process is created and
                    762: an attempt is made to execute the command via
                    763: .IR exec (2).
                    764: .PP
                    765: The shell parameter
                    766: .B
                    767: .SM PATH
                    768: defines the search path for
                    769: the directory containing the command.
                    770: Alternative directory names are separated by
                    771: a colon
                    772: .RB ( : ).
                    773: The default path is
                    774: .B :/bin:/usr/bin
                    775: (specifying the current directory,
                    776: .BR /bin ,
                    777: and
                    778: .BR /usr/bin ,
                    779: in that order).
                    780: Note that the current directory is specified by a null path name,
                    781: which can appear immediately after the equal sign
                    782: or between the colon delimiters anywhere else in the path list.
                    783: If the command name contains a \f3/\fP then the search path
                    784: is not used.
                    785: Otherwise, each directory in the path is
                    786: searched for an executable file.
                    787: If the file has execute permission but is not an
                    788: .B a.out
                    789: file,
                    790: it is assumed to be a file containing shell commands.
                    791: A sub-shell (i.e., a separate process) is spawned to read it.
                    792: A parenthesized command is also executed in
                    793: a sub-shell.
                    794: .SS Special Commands.
                    795: The following commands are executed in the shell process
                    796: and, except as specified,
                    797: no input/output redirection is permitted for such commands:
                    798: .PP
                    799: .PD 0
                    800: .TP
                    801: .B :
                    802: No effect; the command does nothing.
                    803: A zero exit code is returned.
                    804: .br
                    805: .TP
                    806: .BI ".\| " file\^
                    807: Read and execute commands from
                    808: .I file\^
                    809: and return.
                    810: The search path
                    811: specified by
                    812: .B
                    813: .SM PATH
                    814: is used to find the directory containing
                    815: .IR file .
                    816: .TP
                    817: \f3break\fP \*(OK \f2n\^\fP \*(CK
                    818: Exit from the enclosing \f3for\fP or
                    819: .B while
                    820: loop, if any.
                    821: If
                    822: .I n\^
                    823: is specified then break
                    824: .I n\^
                    825: levels.
                    826: .TP
                    827: \f3continue\fP \*(OK \f2n\^\fP \*(CK
                    828: Resume the next iteration of the enclosing
                    829: \f3for\fP or
                    830: .B while
                    831: loop.
                    832: If
                    833: .I n\^
                    834: is specified then resume at the
                    835: .IR n -th
                    836: enclosing loop.
                    837: .TP
                    838: \f3cd\fP \*(OK \f2arg\^\fP \*(CK
                    839: Change the current directory to
                    840: .IR arg .
                    841: The shell
                    842: parameter
                    843: .B
                    844: .SM HOME
                    845: is the default
                    846: .IR arg .
                    847: .br
                    848: .ne 2.1v
                    849: .TP
                    850: \f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
                    851: The arguments are read as input
                    852: to the shell
                    853: and the resulting command(s) executed.
                    854: .TP
                    855: \f3exec\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
                    856: The command specified by
                    857: the arguments is executed in place of this shell
                    858: without creating a new process.
                    859: Input/output arguments may appear and, if no other
                    860: arguments are given, cause the shell
                    861: input/output to be modified.
                    862: .TP
                    863: \f3exit\fP \*(OK \f2n\^\fP \*(CK
                    864: Causes a shell to exit
                    865: with the exit status specified by
                    866: .IR n .
                    867: If
                    868: .I n\^
                    869: is omitted then the exit status is that of the last command executed
                    870: (an end-of-file will also cause the shell to exit.)
                    871: .TP
                    872: \f3export\fP \*(OK \f2name\^\fP .\|.\|. \*(CK
                    873: The given
                    874: .IR name s
                    875: are marked
                    876: for automatic export to the
                    877: .I environment\^
                    878: of subsequently-executed commands.
                    879: If no arguments are given, then a list of all
                    880: names that are exported in this shell is printed.
                    881: .TP
                    882: \f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
                    883: Equivalent to
                    884: .BI "exec newgrp" " arg\^"
                    885: \&.\|.\|.\|.
                    886: .TP
                    887: \f3read\fP \*(OK \f2name\^\fP .\|.\|. \*(CK
                    888: One line is read from the standard input and
                    889: the first
                    890: word is assigned to the first
                    891: .IR name ,
                    892: the second word
                    893: to the second
                    894: .IR name ,
                    895: etc., with leftover words assigned to the last
                    896: .IR name .
                    897: The return code is 0 unless an end-of-file is encountered.
                    898: .TP
                    899: \f3readonly\fP \*(OK \f2name\^\fP .\|.\|. \*(CK
                    900: The given
                    901: .IR name s
                    902: are marked
                    903: .I readonly\^
                    904: and
                    905: the values of the these
                    906: .IR name s
                    907: may not be changed
                    908: by subsequent assignment.
                    909: If no arguments are given, then a list
                    910: of all
                    911: .I readonly\^
                    912: names is printed.
                    913: .TP
                    914: \f3set\fP \*(OK \f3\-ekntuvx\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK \*(CK
                    915: .RS
                    916: .TP
                    917: .B \-e
                    918: If the shell is non-interactive then exit immediately if a command
                    919: exits with a non-zero exit status.
                    920: .TP
                    921: .B \-k
                    922: All keyword arguments are placed in the environment for a command,
                    923: not just those that precede the command name.
                    924: .TP
                    925: .B \-n
                    926: Read commands but do not execute them.
                    927: .TP
                    928: .B \-t
                    929: Exit after reading and executing one command.
                    930: .TP
                    931: .B \-u
                    932: Treat unset variables as an error when substituting.
                    933: .TP
                    934: .B \-v
                    935: Print shell input lines as they are read.
                    936: .TP
                    937: .B \-x
                    938: Print commands and their arguments as they are executed.
                    939: .TP
                    940: .B \-\-
                    941: Do not change any of the flags; useful in setting $1 to -.
                    942: .PP
                    943: Using
                    944: .B \+
                    945: rather than
                    946: .B \-
                    947: causes these flags to be turned off.
                    948: These flags can also be used upon invocation of the shell.
                    949: The current set of flags may be found in
                    950: .BR $\- .
                    951: The remaining arguments are positional
                    952: parameters and are assigned, in order, to
                    953: .BR $1 ,
                    954: .BR $2 ,
                    955: \&.\|.\|.\|.
                    956: If no arguments are given then the values
                    957: of all names are printed.
                    958: .RE
                    959: .TP
                    960: \f3shift\fP
                    961: .br
                    962: The positional parameters from
                    963: .B $2
                    964: \&.\|.\|.
                    965: are renamed
                    966: .B $1
                    967: \&.\|.\|.\|.
                    968: .TP
                    969: \f3test\fP
                    970: .br
                    971: Evaluate conditional expressions. See
                    972: .IR test (1)
                    973: for usage and description.
                    974: .TP
                    975: \f3times\fP
                    976: .br
                    977: Print the accumulated user and system times for processes
                    978: run from the shell.
                    979: .TP
                    980: \f3trap\fP \*(OK \f2arg\^\fP \*(CK \*(OK \f2n\^\fP \*(CK .\|.\|.
                    981: .I arg\^
                    982: is a command to be read and executed when the shell
                    983: receives signal(s)
                    984: .IR n .
                    985: (Note that
                    986: .I arg\^
                    987: is scanned once when
                    988: the trap is set and once when the trap
                    989: is taken.)
                    990: Trap commands are executed in order of signal number.
                    991: Any attempt to set a trap on a signal that
                    992: was ignored on entry to the current shell
                    993: is ineffective.
                    994: An attempt to trap on signal 11 (memory fault) produces an error.
                    995: If
                    996: .I arg\^
                    997: is absent then all trap(s)
                    998: .I n\^
                    999: are reset
                   1000: to their original values.
                   1001: If
                   1002: .I arg\^
                   1003: is the null
                   1004: string then this signal is ignored by the shell and by the commands
                   1005: it invokes.
                   1006: If
                   1007: .I n\^
                   1008: is 0 then the command
                   1009: .I arg\^
                   1010: is executed
                   1011: on exit from the shell.
                   1012: The
                   1013: .B trap
                   1014: command
                   1015: with no arguments prints a list
                   1016: of commands associated with each signal number.
                   1017: .TP
                   1018: \f3umask\fP \*(OK \f2nnn\^\fP \*(CK
                   1019: The user file-creation mask is set to
                   1020: .I nnn\^
                   1021: (see
                   1022: .IR umask (2)).
                   1023: If
                   1024: .I nnn\^
                   1025: is omitted, the current value of the mask is printed.
                   1026: .TP
                   1027: \f3wait\fP
                   1028: Wait for all child processes to terminate
                   1029: report the termination status.
                   1030: If
                   1031: .I n\^
                   1032: is not given then all currently active child processes are waited for.
                   1033: The return code from this command is always zero.
                   1034: .PD
                   1035: .PP
                   1036: .SS Invocation.
                   1037: If the shell is invoked through
                   1038: .IR exec (2)
                   1039: and the first character of argument zero
                   1040: is
                   1041: .BR \- ,
                   1042: commands are initially read from
                   1043: .B /etc/profile
                   1044: and then from
                   1045: .BR \s-1$HOME\s+1/.profile ,
                   1046: if such files exist.
                   1047: Thereafter, commands are read as described below, which
                   1048: is also the case when the shell is invoked as
                   1049: .BR /bin/sh .
                   1050: The flags below are interpreted by the shell on invocation only; Note
                   1051: that unless the 
                   1052: .B \-c
                   1053: or
                   1054: .B \-s
                   1055: flag is specified, the first argument is assumed to be the
                   1056: name of a file containing commands, and the remaining
                   1057: arguments are passed as positional parameters
                   1058: to that command file:
                   1059: .PP
                   1060: .PD 0
                   1061: .TP 10
                   1062: .BI \-c "\| string\^"
                   1063: If the
                   1064: .B \-c
                   1065: flag is present then
                   1066: commands are read from
                   1067: .IR string .
                   1068: .TP
                   1069: .B \-s
                   1070: If the
                   1071: .B \-s
                   1072: flag is present or if no
                   1073: arguments remain
                   1074: then commands are read from the standard input.
                   1075: Any remaining arguments specify the positional parameters.
                   1076: Shell output is written to
                   1077: file descriptor 2.
                   1078: .TP
                   1079: .B \-i
                   1080: If the
                   1081: .B \-i
                   1082: flag is present or
                   1083: if the shell input and output are attached to a terminal,
                   1084: then this shell is
                   1085: .IR interactive .
                   1086: In this case \s-1TERMINATE\s+1 is ignored (so that \f3kill 0\fP
                   1087: does not kill an interactive shell) and \s-1INTERRUPT\s+1 is caught and ignored
                   1088: (so that
                   1089: .B wait
                   1090: is interruptible).
                   1091: In all cases, \s-1QUIT\s+1 is ignored by the shell.
                   1092: .PD
                   1093: .PP
                   1094: The remaining flags and arguments are described under the
                   1095: .B set
                   1096: command above.
                   1097: .PP
                   1098: .SH EXIT STATUS
                   1099: Errors detected by the shell, such as syntax errors,
                   1100: cause the shell
                   1101: to return a non-zero exit status.
                   1102: If the shell is being used non-interactively
                   1103: then execution of the shell file is abandoned.
                   1104: Otherwise, the shell returns the exit status of
                   1105: the last command executed (see also the
                   1106: .B exit
                   1107: command above).
                   1108: .SH FILES
                   1109: /etc/profile
                   1110: .br
                   1111: \s-1$HOME\s+1/\f3.\fPprofile
                   1112: .br
                   1113: /tmp/sh\(**
                   1114: .br
                   1115: /dev/null
                   1116: .SH SEE ALSO
                   1117: cd(1),
                   1118: env(1),
                   1119: login(1),
                   1120: newgrp(1),
                   1121: rsh(1),
                   1122: test(1),
                   1123: umask(1),
                   1124: dup(2),
                   1125: exec(2),
                   1126: fork(2),
                   1127: pipe(2),
                   1128: signal(2),
                   1129: ulimit(2),
                   1130: umask(2),
                   1131: wait(2),
                   1132: a.out(5),
                   1133: profile(5),
                   1134: environ(7).
                   1135: .SH BUGS
                   1136: The command
                   1137: .B readonly
                   1138: (without arguments) produces the same output as the command
                   1139: .BR export .
                   1140: .br
                   1141: If
                   1142: .B <\[email protected]@<
                   1143: is used to provide standard input to an
                   1144: asynchronous process invoked by
                   1145: .BR & ,
                   1146: the shell gets mixed up about naming
                   1147: the input document;
                   1148: a garbage file
                   1149: .B /tmp/sh\(**
                   1150: is created and the shell complains about not being able
                   1151: to find that file by another name.

unix.superglobalmegacorp.com

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