1 '\" te
   2 .\" Copyright (c) 1982-2007 AT&T Knowledge Ventures
   3 .\" To view license terms, see http://www.opensource.org/licenses/cpl1.0.txt
   4 .\" Portions Copyright (c) 2009, Sun Microsystems, Inc.
   5 .TH KSH93 1 "Sep 10, 2013"
   6 .SH NAME
   7 ksh93, rksh93 \- Korn Shell, a standard and restricted command and programming
   8 language
   9 .SH SYNOPSIS
  10 .LP
  11 .nf
  12 \fBksh93\fR [\fB\(+-abcefhikmnoprstuvxBCD\fR] [\fB-R\fR \fIfile\fR] [ \fB\(+-o\fR \fIoption\fR] ...
  13        [-] [\fIarg\fR ...]
  14 .fi
  15 
  16 .LP
  17 .nf
  18 \fBrksh93\fR [\fB\(+-abcefhikmnoprstuvxBCD\fR] [\fB-R\fR \fIfile\fR] [\fB\(+-o\fR \fIoption\fR] ...
  19        [-] [\fIarg\fR ...]
  20 .fi
  21 
  22 .SH DESCRIPTION
  23 .sp
  24 .LP
  25 \fBksh93\fR is a command and programming language that executes commands read
  26 from a terminal or a file. \fBrksh93\fR is a restricted version of the command
  27 interpreter \fBksh93\fR. \fBrksh93\fR is used to set up login names and
  28 execution environments whose capabilities are more controlled than those of the
  29 standard shell.
  30 .sp
  31 .LP
  32 See \fBInvocation\fR for the meaning of arguments to the shell.
  33 .SS "Definitions"
  34 .sp
  35 .LP
  36 A \fImetacharacter\fR is defined as one of the following characters:
  37 .sp
  38 .in +2
  39 .nf
  40 ; & ( ) | < > NEWLINE SPACE TAB
  41 .fi
  42 .in -2
  43 .sp
  44 
  45 .sp
  46 .LP
  47 A \fIblank\fR is a \fBTAB\fR or a \fBSPACE\fR.
  48 .sp
  49 .LP
  50 An \fIidentifier\fR is a sequence of letters, digits, or underscores starting
  51 with a letter or underscore. Identifiers are used as components of \fIvariable
  52 names\fR.
  53 .sp
  54 .LP
  55 A \fIvname\fR is a sequence of one or more identifiers separated by a period
  56 (\fB\&.\fR) and optionally preceded by a period (\fB\&.\fR). \fIvnames\fR are
  57 used as function and variable names.
  58 .sp
  59 .LP
  60 A \fIword\fR is a sequence of \fIcharacters\fR from the character set defined
  61 by the current locale, excluding non-quoted \fImetacharacters\fR.
  62 .sp
  63 .LP
  64 A \fIcommand\fR is a sequence of characters in the syntax of the shell
  65 language. The shell reads each command and carries out the desired action
  66 either directly or by invoking separate utilities. A built-in command is a
  67 command that is carried out by the shell itself without creating a separate
  68 process. Some commands are built-in purely for convenience and are not
  69 documented in this manual page. Built-ins that cause side effects in the shell
  70 environment and built-ins that are found before performing a path search (see
  71 \fBExecution\fR) are documented in this manual page. For historical reasons,
  72 some of these built-ins behave differently than other built-ins and are called
  73 special built-ins.
  74 .SS "Commands"
  75 .sp
  76 .LP
  77 A \fIsimple-command\fR is a list of variable assignments (see \fBVariable
  78 Assignments\fR) or a sequence of \fIblank\fR-separated words which can be
  79 preceded by a list of variable assignments. See the \fBEnvironment\fR section
  80 of this manual page.
  81 .sp
  82 .LP
  83 The first word specifies the name of the command to be executed. Except as
  84 specified in this section, the remaining words are passed as arguments to the
  85 invoked command. The command name is passed as argument 0. See \fBexec\fR(2).
  86 The \fIvalue\fR of a simple-command is its exit status. If it terminates
  87 normally, its value is \fB0\fR-\fB255\fR. If it terminates abnormally, its
  88 value is \fB256+\fR\fIsignum\fR. The name of the signal corresponding to the
  89 exit status can be obtained by way of the \fB-l\fR option of the kill built-in
  90 utility.
  91 .sp
  92 .LP
  93 A \fIpipeline\fR is a sequence of one or more commands separated by \fB|\fR.
  94 The standard output of each command but the last is connected by a
  95 \fBpipe\fR(2) to the standard input of the next command. Each command, except
  96 possibly the last, is run as a separate process. The shell waits for the last
  97 command to terminate. The exit status of a pipeline is the exit status of the
  98 last command unless the \fBpipefail\fR option is enabled. Each pipeline can be
  99 preceded by the reserved word\fB!\fR. This causes the exit status of the
 100 pipeline to become \fB0\fR if the exit status of the last command is
 101 \fBnon-zero\fR, and \fB1\fR if the exit status of the last command is \fB0\fR.
 102 .sp
 103 .LP
 104 A \fIlist\fR is a sequence of one or more pipelines separated by \fB;, &, |&,
 105 &&, or |\fR, and optionally terminated by \fB;, &,\fR or \fB|&\fR. Of these
 106 five symbols, \fB;, &\fR, and \fB|&\fR have equal precedence, which is lower
 107 than that of \fB&&\fR and \fB||\fR. The symbols \fB&&\fR and \fB||\fR also have
 108 equal precedence.
 109 .sp
 110 .LP
 111 A semicolon (\fB;\fR) causes sequential execution of the preceding pipeline. An
 112 ampersand (\fB&\fR) causes asynchronous execution of the preceding pipeline,
 113 that is, the shell does \fInot\fR wait for that pipeline to finish. The symbol
 114 \fB|&\fR causes asynchronous execution of the preceding pipeline with a two-way
 115 pipe established to the parent shell. The standard input and output of the
 116 spawned pipeline can be written to and read from by the parent shell by
 117 applying the redirection operators \fB<&\fR and \fB>&\fR with \fBarg p\fR to
 118 commands and by using \fB-p\fR option of the built-in commands \fBread\fR and
 119 \fBprint\fR. The symbol \fB&&\fR (\fB||\fR) causes the \fIlist\fR following it
 120 to be executed only if the preceding pipeline returns a zero (\fBnon-zero\fR)
 121 value. One or more NEWLINEs can appear in a \fIlist\fR instead of a semicolon,
 122 to delimit a command. The first \fIitem\fR of the first \fIpipeline\fR of a
 123 \fIlist\fR that is a simple command not beginning with a redirection, and not
 124 occurring within a \fBwhile\fR, \fBuntil\fR, or \fBif\fR \fIlist\fR , can be
 125 preceded by a semicolon. This semicolon is ignored unless the \fBshowme\fR
 126 option is enabled as described with the \fBset\fR built-in.
 127 .sp
 128 .LP
 129 A \fIcommand\fR is either a simple-command or one of commands in the following
 130 list. Unless otherwise stated, the value returned by a command is that of the
 131 last simple-command executed in the command.
 132 .sp
 133 .ne 2
 134 .na
 135 \fB\fBfor\fR \fIvname\fR \fB[ in\fR \fIword\fR \fB\&... ] ;do\fR \fIlist\fR
 136 \fB;done\fR\fR
 137 .ad
 138 .sp .6
 139 .RS 4n
 140 Each time a \fBfor\fR command is executed, \fIvname\fR is set to the next
 141 \fIword\fR taken from the \fBin\fR \fIword\fR list. If \fBin\fR \fIword ...\fR
 142 is omitted, the \fBfor\fR command executes the \fBdo\fR \fIlist\fR once for
 143 each positional parameter that is set starting from 1. Execution ends when
 144 there are no more words in the list. See \fBParameter Expansion\fR.
 145 .RE
 146 
 147 .sp
 148 .ne 2
 149 .na
 150 \fB\fB(( [\fR\fIexpr1\fR\fB] ; [\fR\fIexpr2\fR] ; [\fIexpr3\fR\fB] )) ;do\fR
 151 \fIlist\fR \fB;done\fR\fR
 152 .ad
 153 .sp .6
 154 .RS 4n
 155 The arithmetic expression \fIexpr1\fR is evaluated first. The arithmetic
 156 expression \fIexpr2\fR is repeatedly evaluated until it evaluates to \fBzero\fR
 157 and when \fBnon-zero\fR, \fIlist\fR is executed and the arithmetic expression
 158 \fIexpr3\fR evaluated. If any expression is omitted, then it behaves as if it
 159 evaluated to \fB1\fR. See \fBArithmetic Evaluation\fR.
 160 .RE
 161 
 162 .sp
 163 .ne 2
 164 .na
 165 \fB\fBselect\fR \fIvname\fR [ in \fIword\fR \fB\&... ] ;do\fR \fIlist\fR
 166 \fB;done\fR\fR
 167 .ad
 168 .sp .6
 169 .RS 4n
 170 A \fBselect\fR command prints on standard error (file descriptor 2) the set of
 171 \fIwords\fR, each preceded by a number. If \fBin\fR \fIword...\fR is omitted,
 172 the positional parameters starting from \fB1\fR are used instead. See
 173 \fBParameter Expansion\fR. The \fBPS3\fR prompt is printed and a line is read
 174 from the standard input. If this line consists of the number of one of the
 175 listed \fIword\fRs, then the value of the variable \fIvname\fR is set to the
 176 \fIword\fR corresponding to this number. If this line is empty, the selection
 177 list is printed again. Otherwise the value of the variable \fIvname\fR is set
 178 to \fBnull\fR. The contents of the line read from standard input is saved in
 179 the variable \fBREPLY\fR. The \fIlist\fR is executed for each selection until a
 180 break or \fBEOF\fR is encountered. If the \fBREPLY\fR variable is set to
 181 \fBnull\fR by the execution of \fIlist\fR, the selection list is printed before
 182 displaying the \fBPS3\fR prompt for the next selection.
 183 .RE
 184 
 185 .sp
 186 .ne 2
 187 .na
 188 \fB\fBcase\fR \fIword\fR \fBin [ [(]\fR \fIpattern\fR \fB[ |\fR \fIpattern\fR
 189 \fB] ... )\fR \fIlist\fR \fB;; ] ... esac\fR\fR
 190 .ad
 191 .sp .6
 192 .RS 4n
 193 A \fBcase\fR command executes the \fIlist\fR associated with the first
 194 \fIpattern\fR that matches \fIword\fR. The form of the patterns is the same as
 195 that used for file name generation. See \fBFile Name Generation\fR.
 196 .sp
 197 The \fB;;\fR operator causes execution of \fBcase\fR to terminate. If \fB;&\fR
 198 is used in place of \fB;;\fR the next subsequent list, if any, is executed.
 199 .RE
 200 
 201 .sp
 202 .ne 2
 203 .na
 204 \fB\fBif\fR \fIlist\fR \fB;then\fR \fIlist\fR \fB[ ;elif\fR \fIlist\fR
 205 \fB;then\fR \fIlist\fR ] \fB\&... [ ;else\fR \fIlist\fR \fB]\fR \fB;fi\fR\fR
 206 .ad
 207 .sp .6
 208 .RS 4n
 209 The \fIlist\fR following \fBif\fR is executed and, if it returns a \fBzero\fR
 210 exit status, the \fIlist\fR following the first \fBthen\fR is executed.
 211 Otherwise, the \fIlist\fR following \fBelif\fR is executed, and, if its value
 212 is \fBzero\fR, the \fIlist\fR following the next \fBthen\fR is executed.
 213 Failing each successive \fBelif\fR \fIlist\fR, the \fBelse\fR \fIlist\fR is
 214 executed. If the \fBif\fR \fIlist\fR has \fBnon-zero\fR exit status and there
 215 is no \fBelse\fR \fIlist\fR, then the \fBif\fR command returns a \fBzero\fR
 216 exit status.
 217 .RE
 218 
 219 .sp
 220 .ne 2
 221 .na
 222 \fB\fBwhile\fR \fIlist\fR \fB;do\fR \fIlist\fR \fB;done\fR\fR
 223 .ad
 224 .br
 225 .na
 226 \fBuntil \fIlist\fR \fB;do\fR \fIlist\fR \fB;done\fR\fR
 227 .ad
 228 .sp .6
 229 .RS 4n
 230 A \fBwhile\fR command repeatedly executes the while \fIlist\fR and, if the exit
 231 status of the last command in the list is zero, executes the \fBdo\fR
 232 \fIlist\fR, otherwise the loop terminates. If no commands in the \fBdo\fR
 233 \fIlist\fR are executed, then the \fBwhile\fR command returns a \fBzero\fR exit
 234 status, \fBuntil\fR can be used in place of \fBwhile\fR to negate the loop
 235 termination test.
 236 .RE
 237 
 238 .sp
 239 .ne 2
 240 .na
 241 \fB\fB((\fR\fIexpression\fR\fB))\fR\fR
 242 .ad
 243 .sp .6
 244 .RS 4n
 245 The \fIexpression\fR is evaluated using the rules for arithmetic evaluation
 246 described in this manual page. If the value of the arithmetic expression is
 247 \fBnon-zero\fR, the exit status is \fB0\fR. Otherwise the exit status is
 248 \fB1\fR.
 249 .RE
 250 
 251 .sp
 252 .ne 2
 253 .na
 254 \fB\fB(\fR\fIlist\fR\fB;)\fR\fR
 255 .ad
 256 .sp .6
 257 .RS 4n
 258 Execute list in a separate environment. If two adjacent open parentheses are
 259 needed for nesting, a SPACE must be inserted to avoid evaluation as an
 260 arithmetic command as described in this section.
 261 .sp
 262 \fIlist\fR is simply executed. Unlike the metacharacters, \fB(\fR and \fB)\fR,
 263 \fB{\fR and \fB}\fR are \fIreserved words\fR and must occur at the beginning of
 264 a line or after a \fB;\fR to be recognized.
 265 .RE
 266 
 267 .sp
 268 .ne 2
 269 .na
 270 \fB\fB[[\fR \fIexpression\fR \fB]]\fR\fR
 271 .ad
 272 .sp .6
 273 .RS 4n
 274 Evaluates \fIexpression\fR and returns a \fBzero\fR exit status when
 275 \fIexpression\fR is true. See \fBConditional Expressions\fR for a description
 276 of \fIexpression\fR.
 277 .RE
 278 
 279 .sp
 280 .ne 2
 281 .na
 282 \fB\fBfunction\fR \fIvarname\fR \fB{\fR \fIlist\fR \fB;}\fR\fR
 283 .ad
 284 .br
 285 .na
 286 \fB\fIvarname\fR \fB() {\fR \fIlist\fR \fB;}\fR\fR
 287 .ad
 288 .sp .6
 289 .RS 4n
 290 Define a function which is referenced by \fIvarname\fR. A function whose
 291 \fIvarname\fR contains a \fB\&.\fR is called a discipline function and the
 292 portion of the \fIvarname\fR preceding the last \fB\&.\fR must refer to an
 293 existing variable.
 294 .sp
 295 The body of the function is the \fIlist\fR of commands between \fB{\fR and
 296 \fB}\fR. A function defined with the function \fIvarname\fR syntax can also be
 297 used as an argument to the \fB\&.\fR special built-in command to get the
 298 equivalent behavior as if the \fIvarname\fR\fB()\fR syntax were used to define
 299 it. See \fBFunctions\fR.
 300 .RE
 301 
 302 .sp
 303 .ne 2
 304 .na
 305 \fB\fBtime [\fR \fIpipeline\fR \fB]\fR\fR
 306 .ad
 307 .sp .6
 308 .RS 4n
 309 If \fIpipeline\fR is omitted, the user and system time for the current shell
 310 and completed child processes is printed on standard error. Otherwise,
 311 \fIpipeline\fR is executed and the elapsed time as well as the user and system
 312 time are printed on standard error. The \fBTIMEFORMAT\fR variable can be set to
 313 a format string that specifies how the timing information should be displayed.
 314 See \fBShell Variables\fR for a description of the \fBTIMEFORMAT\fR variable.
 315 .RE
 316 
 317 .sp
 318 .LP
 319 The following reserved words are recognized as reserved only when they are the
 320 first word of a command and are not quoted:
 321 .br
 322 .in +2
 323 \fBcase\fR
 324 .in -2
 325 .br
 326 .in +2
 327 \fBdo\fR
 328 .in -2
 329 .br
 330 .in +2
 331 \fBdone\fR
 332 .in -2
 333 .br
 334 .in +2
 335 \fBelse\fR
 336 .in -2
 337 .br
 338 .in +2
 339 \fBelif\fR
 340 .in -2
 341 .br
 342 .in +2
 343 \fBesac\fR
 344 .in -2
 345 .br
 346 .in +2
 347 \fBfor\fR
 348 .in -2
 349 .br
 350 .in +2
 351 \fBfi\fR
 352 .in -2
 353 .br
 354 .in +2
 355 \fBfunction\fR
 356 .in -2
 357 .br
 358 .in +2
 359 \fBif\fR
 360 .in -2
 361 .br
 362 .in +2
 363 \fBselect\fR
 364 .in -2
 365 .br
 366 .in +2
 367 \fBthen\fR
 368 .in -2
 369 .br
 370 .in +2
 371 \fBtime\fR
 372 .in -2
 373 .br
 374 .in +2
 375 \fBuntil\fR
 376 .in -2
 377 .br
 378 .in +2
 379 \fBwhile\fR
 380 .in -2
 381 .br
 382 .in +2
 383 \fB{ }\fR
 384 .in -2
 385 .br
 386 .in +2
 387 \fB[[ ]]\fR
 388 .in -2
 389 .br
 390 .in +2
 391 \fB!\fR
 392 .in -2
 393 .SS "Variable Assignments"
 394 .sp
 395 .LP
 396 One or more variable assignments can start a simple command or can be arguments
 397 to the \fBtypeset\fR, \fBexport\fR, or \fBreadonly\fR special built-in
 398 commands. The syntax for an \fIassignment\fR is of the form:
 399 .sp
 400 .ne 2
 401 .na
 402 \fB\fIvarname\fR\fB=\fR\fIword\fR\fR
 403 .ad
 404 .br
 405 .na
 406 \fB\fIvarname\fR\fB[\fR\fIword\fR\fB]=\fR\fIword\fR\fR
 407 .ad
 408 .sp .6
 409 .RS 4n
 410 No space is permitted between \fIvarname\fR and the \fB=\fR or between \fB=\fR
 411 and \fIword\fR.
 412 .RE
 413 
 414 .sp
 415 .ne 2
 416 .na
 417 \fB\fIvarname\fR\fB=(\fR\fIassignlist\fR\fB)\fR\fR
 418 .ad
 419 .sp .6
 420 .RS 4n
 421 No space is permitted between \fIvarname\fR and the \fB=\fR. An
 422 \fIassignlist\fR can be one of the following:
 423 .sp
 424 .ne 2
 425 .na
 426 \fB\fIword ...\fR\fR
 427 .ad
 428 .sp .6
 429 .RS 4n
 430 Indexed array assignment.
 431 .RE
 432 
 433 .sp
 434 .ne 2
 435 .na
 436 \fB\fB[\fR\fIword\fR\fB]=\fR\fIword ...\fR\fR
 437 .ad
 438 .sp .6
 439 .RS 4n
 440 Associative array assignment. If prefixed by \fBtypeset\fR \fB-a\fR, creates an
 441 indexed array instead.
 442 .RE
 443 
 444 .sp
 445 .ne 2
 446 .na
 447 \fB\fIassignment ...\fR\fR
 448 .ad
 449 .sp .6
 450 .RS 4n
 451 Compound variable assignment. This creates a compound variable \fIvarname\fR
 452 with sub-variables of the form \fIvarname.name\fR, where \fIname\fR is the name
 453 portion of assignment. The value of \fIvarname\fR contains all the assignment
 454 elements. Additional assignments made to sub-variables of \fIvarname\fR are
 455 also displayed as part of the value of \fIvarname\fR. If no \fIassignment\fRs
 456 are specified, \fIvarname\fR is a compound variable allowing subsequence child
 457 elements to be defined.
 458 .RE
 459 
 460 .sp
 461 .ne 2
 462 .na
 463 \fB\fBtypeset [\fR\fIoptions\fR] \fIassignment\fR \fB\&...\fR\fR
 464 .ad
 465 .sp .6
 466 .RS 4n
 467 Nested variable assignment. Multiple assignments can be specified by separating
 468 each of them with a \fB;\fR. The previous value is unset before the assignment.
 469 .RE
 470 
 471 In addition, a \fB+=\fR can be used in place of the \fB=\fR to signify adding
 472 to or appending to the previous value. When \fB+=\fR is applied to an
 473 arithmetic type, \fIword\fR is evaluated as an arithmetic expression and added
 474 to the current value. When applied to a string variable, the value defined by
 475 \fIword\fR is appended to the value. For compound assignments, the previous
 476 value is not unset and the new values are appended to the current ones provided
 477 that the types are compatible.
 478 .RE
 479 
 480 .SS "Comments"
 481 .sp
 482 .LP
 483 A word beginning with \fB#\fR causes that word and all the following characters
 484 up to a NEWLINE to be commented, or ignored.
 485 .SS "Aliasing"
 486 .sp
 487 .LP
 488 The first word of each command is replaced by the text of an alias if an alias
 489 for this word has been defined. An alias name consists of any number of
 490 characters excluding metacharacters, quoting characters, file expansion
 491 characters, parameter expansion characters, command substitution characters,
 492 and \fB=\fR. The replacement string can contain any valid shell script
 493 including the metacharacters listed in the \fBCommands\fR section. The first
 494 word of each command in the replaced text, other than any that are in the
 495 process of being replaced, are tested for aliases. If the last character of the
 496 alias value is a BLANK then the word following the alias is also checked for
 497 alias substitution.
 498 .sp
 499 .LP
 500 Aliases can be used to redefine built-in commands but cannot be used to
 501 redefine the reserved words listed in the \fBCommands\fR section. Aliases can
 502 be created and listed with the alias command and can be removed with the
 503 \fBunalias\fR command.
 504 .sp
 505 .LP
 506 Aliasing is performed when scripts are read, not while they are executed. For
 507 an alias to take effect, the \fBalias\fR definition command has to be executed
 508 before the command which references the alias is read. The following aliases
 509 are compiled into the shell but can be unset or redefined:
 510 .sp
 511 .in +2
 512 .nf
 513 autoload='typeset -fu'
 514 command='command '
 515 fc=hist
 516 float='typeset -lE'
 517 functions='typeset -f'
 518 hash='alias -t --'
 519 history='hist -l'
 520 integer='typeset -li'
 521 nameref='typeset -n'
 522 nohup='nohup '
 523 r='hist -s'
 524 redirect='command exec'
 525 source='command .'
 526 stop='kill -s STOP'
 527 suspend='kill -s STOP $$'
 528 times='{ { time;} 2>&1;}'
 529 type='whence -v'
 530 .fi
 531 .in -2
 532 .sp
 533 
 534 .SS "Tilde Substitution"
 535 .sp
 536 .LP
 537 After alias substitution is performed, each word is checked to see if it begins
 538 with an unquoted tilde (\fB~\fR). For tilde substitution, \fIword\fR also
 539 refers to the \fIword\fR portion of parameter expansion. See \fBParameter
 540 Expansion\fR.
 541 .sp
 542 .LP
 543 If it does, the word up to a \fB/\fR is checked to see if it matches a user
 544 name in the password database. If a match is found, the \fB~\fR and the matched
 545 login name are replaced by the login directory of the matched user. If no match
 546 is found, the original text is left unchanged. A \fB~\fR by itself, or in front
 547 of a \fB/\fR, is replaced by \fB$HOME\fR. A \fB~\fR followed by a \fB+\fR or
 548 \fB-\fR is replaced by the value of \fB$PWD\fR and \fB$OLDPWD\fR respectively.
 549 .sp
 550 .LP
 551 In addition, when expanding a \fIvariable assignment\fR, tilde substitution is
 552 attempted when the value of the assignment begins with a \fB~\fR, and when a
 553 \fB~\fR appears after a colon (\fB:\fR). The \fB:\fR also terminates a \fB~\fR
 554 login name.
 555 .SS "Command Substitution"
 556 .sp
 557 .LP
 558 The standard output from a command enclosed in parentheses preceded by a dollar
 559 sign (\fB$\fR) or a pair of grave accents (\fB``\fR) can be used as part or all
 560 of a word. Trailing NEWLINEs are removed. In the second (obsolete) form, the
 561 string between the quotes is processed for special quoting characters before
 562 the command is executed. See \fBQuoting\fR.
 563 .sp
 564 .LP
 565 The command substitution \fB$(cat file)\fR can be replaced by the equivalent
 566 but faster \fB$(<file)\fR. The command substitution \fB$(\fR\fIn\fR\fB<#)\fR
 567 expands to the current byte offset for file descriptor \fIn\fR.
 568 .SS "Arithmetic Substitution"
 569 .sp
 570 .LP
 571 An arithmetic expression enclosed in double parentheses preceded by a dollar
 572 sign ( \fB$((\fR\fIarithmetic_expression\fR\fB))\fR) is replaced by the value
 573 of the arithmetic expression within the double parentheses.
 574 .SS "Process Substitution"
 575 .sp
 576 .LP
 577 Process substitution is only available on versions of the UNIX operating system
 578 that support the \fB/dev/fd\fR directory for naming open files.
 579 .sp
 580 .LP
 581 Each command argument of the form \fB<(\fR\fIlist\fR\fB)\fR or
 582 \fB>(\fR\fIlist\fR\fB)\fR runs process \fIlist\fR asynchronously connected to
 583 some file in \fB/dev/fd\fR. The name of this file becomes the argument to the
 584 command. If the form with \fB>\fR is selected then writing on this file
 585 provides input for \fIlist\fR. If \fB<\fR is used, then the file passed as an
 586 argument contains the output of the \fIlist\fR process.
 587 .sp
 588 .LP
 589 For example,
 590 .sp
 591 .in +2
 592 .nf
 593 paste <(cut -f1 \fIfile1\fR) <(cut -f3 \fIfile2\fR) | tee \e
 594      >(\fIprocess1\fR) >(\fIprocess2\fR)
 595 .fi
 596 .in -2
 597 .sp
 598 
 599 .sp
 600 .LP
 601 \fBcut\fRs fields 1 and 3 from the files \fIfile1\fR and \fIfile2\fR
 602 respectively, \fBpaste\fRs the results together, and sends it to the processes
 603 \fIprocess1\fR and \fIprocess2\fR. It also displays the results to the standard
 604 output. The file, which is passed as an argument to the command, is a UNIX
 605 \fBpipe\fR(2). Programs that expect to \fBlseek\fR(2) on the file do not work.
 606 .SS "Parameter Expansion"
 607 .sp
 608 .LP
 609 A parameter is a variable, one or more digits, or any of the characters
 610 \fB*\fR, \fB@\fR, \fB#\fR, \fB?\fR, \fB-\fR, \fB$\fR, and \fB!\fR. A variable
 611 is denoted by a \fIvname\fR. To create a variable whose \fIvname\fR contains a
 612 \fB\&.\fR, a variable whose \fBvname\fR consists of everything before the
 613 last . must already exist. A variable has a value and zero or more attributes.
 614 Variables can be assigned values and attributes by using the \fBtypeset\fR
 615 special built-in command. The attributes supported by the shell are described
 616 later with the \fBtypeset\fR special built-in command. Exported variables pass
 617 values and attributes to the environment.
 618 .sp
 619 .LP
 620 The shell supports both indexed and associative arrays. An element of an array
 621 variable is referenced by a subscript. A subscript for an indexed array is
 622 denoted by an arithmetic expression, (see \fBArithmetic Evaluation\fR), between
 623 a \fB[\fR and a \fB]\fR. Use \fBset -A\fR \fIvname value ...\fR to assign
 624 values to an indexed array. The value of all subscripts must be in the range of
 625 \fB0\fR through \fB1,048,575\fR. Indexed arrays do not need to be declared. Any
 626 reference to a variable with a valid subscript is legal and an array is created
 627 if necessary.
 628 .sp
 629 .LP
 630 An associative array is created with the \fB-A\fR option to \fBtypeset\fR. A
 631 subscript for an associative array is denoted by a string enclosed between
 632 \fB[\fR and \fB]\fR.
 633 .sp
 634 .LP
 635 Referencing any array without a subscript is equivalent to referencing the
 636 array with subscript \fB0\fR.
 637 .sp
 638 .LP
 639 The value of a variable can be assigned by:
 640 .sp
 641 .in +2
 642 .nf
 643 \fIvname\fR=\fIvalue\fR [\fIvname\fR=\fIvalue\fR] ...
 644 .fi
 645 .in -2
 646 .sp
 647 
 648 .sp
 649 .LP
 650 or
 651 .sp
 652 .in +2
 653 .nf
 654 \fIvname\fR[\fIsubscript\fR]=\fIvalue\fR [\fIvname\fR[\fIsubscript\fR]=\fIvalue\fR] ...
 655 .fi
 656 .in -2
 657 .sp
 658 
 659 .sp
 660 .LP
 661 No space is allowed before or after the \fB=\fR. A \fInameref\fR is a variable
 662 that is a reference to another variable. A \fInameref\fR is created with the
 663 \fB-n\fR attribute of \fBtypeset\fR. The value of the variable at the time of
 664 the \fBtypeset\fR command becomes the variable that is referenced whenever the
 665 \fInameref\fR variable is used. The name of a \fInameref\fR cannot contain a
 666 dot (\fI\&.\fR). When a variable or function name contains a \fB\&.,\fR and the
 667 portion of the name up to the first \fB\&.\fR matches the name of a
 668 \fInameref\fR, the variable referred to is obtained by replacing the
 669 \fInameref\fR portion with the name of the variable referenced by the
 670 \fInameref\fR. If a \fInameref\fR is used as the index of a \fBfor\fR loop, a
 671 name reference is established for each item in the list. A \fInameref\fR
 672 provides a convenient way to refer to the variable inside a function whose name
 673 is passed as an argument to a function. For example, if the name of a variable
 674 is passed as the first argument to a function, the command
 675 .sp
 676 .in +2
 677 .nf
 678  typeset -n var=$1
 679 .fi
 680 .in -2
 681 .sp
 682 
 683 .sp
 684 .LP
 685 inside the function causes references and assignments to \fIvar\fR to be
 686 references and assignments to the variable whose name has been passed to the
 687 function. If either of the floating point attributes, \fB-E\fR, or \fB-F\fR, or
 688 the integer attribute, \fB-i\fR, is set for \fIvname\fR, then the \fIvalue\fR
 689 is subject to arithmetic evaluation as described in this manual page.
 690 Positional parameters, parameters denoted by a number, can be assigned values
 691 with the \fBset\fR special built-in command. Parameter \fB$0\fR is set from
 692 argument zero when the shell is invoked. The character \fB$\fR is used to
 693 introduce substitutable parameters.
 694 .sp
 695 .ne 2
 696 .na
 697 \fB\fB${\fR\fIparameter\fR\fB}\fR\fR
 698 .ad
 699 .sp .6
 700 .RS 4n
 701 The shell reads all the characters from \fB${\fR to the matching \fB}\fR as
 702 part of the same word even if it contains braces or metacharacters. The value,
 703 if any, of the parameter is substituted. The braces are required when
 704 \fIparameter\fR is followed by a letter, digit, or underscore that is not to be
 705 interpreted as part of its name, when the variable name contains a \fB\&.\fR,
 706 or when a variable is subscripted. If \fIparameter\fR is one or more digits
 707 then it is a positional parameter. A positional parameter of more than one
 708 digit must be enclosed in braces. If \fIparameter\fR is \fB*\fR or \fB@\fR,
 709 then all the positional parameters, starting with \fB$1\fR, are substituted and
 710 separated by a field separator character. If an array \fIvname\fR with
 711 subscript \fB*\fR or \fB@\fR is used, then the value for each of the elements
 712 is substituted, separated by the first character of the value of \fBIFS\fR.
 713 .RE
 714 
 715 .sp
 716 .ne 2
 717 .na
 718 \fB\fB${#\fR\fIparameter\fR\fB}\fR\fR
 719 .ad
 720 .sp .6
 721 .RS 4n
 722 If \fIparameter\fR is \fB*\fR or \fB@\fR, the number of positional parameters
 723 is substituted. Otherwise, the length of the value of the \fIparameter\fR is
 724 substituted.
 725 .RE
 726 
 727 .sp
 728 .ne 2
 729 .na
 730 \fB\fB${#\fR\fIvname\fR\fB[*]}\fR\fR
 731 .ad
 732 .br
 733 .na
 734 \fB\fB${#\fR\fIvname\fR\fB[@]}\fR\fR
 735 .ad
 736 .sp .6
 737 .RS 4n
 738 The number of elements in the array \fIvname\fR is substituted.
 739 .RE
 740 
 741 .sp
 742 .ne 2
 743 .na
 744 \fB\fB${!\fR\fIvname\fR\fB}\fR\fR
 745 .ad
 746 .sp .6
 747 .RS 4n
 748 Expands to the name of the variable referred to by \fIvname\fR. This is
 749 \fIvname\fR except when \fIvname\fR is a name reference.
 750 .RE
 751 
 752 .sp
 753 .ne 2
 754 .na
 755 \fB\fB${!\fR\fIvname\fR\fB[\fR\fIsubscript\fR\fB]}\fR\fR
 756 .ad
 757 .sp .6
 758 .RS 4n
 759 Expands to name of the subscript unless \fIsubscript\fR is \fB*\fR or \fB@\fR.
 760 When \fIsubscript\fR is \fB*\fR, the list of array subscripts for \fIvname\fR
 761 is generated. For a variable that is not an array, the value is \fB0\fR if the
 762 variable is set. Otherwise it is \fBnull\fR. When \fIsubscript\fR is \fB@\fR,
 763 it is the same as \fB$ {\fR\fIvname\fR\fB[\fR\fI*\fR\fB]}\fR, except that when
 764 used in double quotes, each array subscript yields a separate argument.
 765 .RE
 766 
 767 .sp
 768 .ne 2
 769 .na
 770 \fB\fB${!\fR\fIprefix\fR\fB*}\fR\fR
 771 .ad
 772 .sp .6
 773 .RS 4n
 774 Expands to the names of the variables whose names begin with \fIprefix\fR.
 775 .RE
 776 
 777 .sp
 778 .ne 2
 779 .na
 780 \fB\fB${\fR\fIparameter\fR\fB:-\fR\fIword\fR\fB}\fR\fR
 781 .ad
 782 .sp .6
 783 .RS 4n
 784 If \fIparameter\fR is set and is non-null then substitute its value. Otherwise
 785 substitute \fIword\fR.
 786 .sp
 787 \fIword\fR is not evaluated unless it is to be used as the substituted string.
 788 .sp
 789 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
 790 is NULL:
 791 .sp
 792 .in +2
 793 .nf
 794 print ${d:-$(pwd)}
 795 .fi
 796 .in -2
 797 .sp
 798 
 799 If the colon (\fB:\fR ) is omitted from the expression, the shell only checks
 800 whether \fIparameter\fR is set or not.
 801 .RE
 802 
 803 .sp
 804 .ne 2
 805 .na
 806 \fB\fB${\fR\fIparameter\fR\fB:=\fR\fIword\fR\fB}\fR\fR
 807 .ad
 808 .sp .6
 809 .RS 4n
 810 If \fIparameter\fR is not set or is \fBnull\fR, set it to \fIword\fR. The value
 811 of the parameter is then substituted. Positional parameters cannot be assigned
 812 to in this way.
 813 .sp
 814 \fIword\fR is not evaluated unless it is to be used as the substituted string.
 815 .sp
 816 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
 817 is NULL:
 818 .sp
 819 .in +2
 820 .nf
 821 print ${d:-$(pwd)}
 822 .fi
 823 .in -2
 824 .sp
 825 
 826 If the colon (\fB:\fR) is omitted from the expression, the shell only checks
 827 whether \fIparameter\fR is set or not.
 828 .RE
 829 
 830 .sp
 831 .ne 2
 832 .na
 833 \fB\fB${\fR\fIparameter\fR\fB:?\fR\fIword\fR\fB}\fR\fR
 834 .ad
 835 .sp .6
 836 .RS 4n
 837 If \fIparameter\fR is set and is non-null, substitute its value. Otherwise,
 838 print \fIword\fR and exit from the shell , if the shell is not interactive. If
 839 \fIword\fR is omitted then a standard message is printed.
 840 .sp
 841 \fIword\fR is not evaluated unless it is to be used as the substituted string.
 842 .sp
 843 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
 844 is NULL:
 845 .sp
 846 .in +2
 847 .nf
 848 print ${d:-$(pwd)}
 849 .fi
 850 .in -2
 851 .sp
 852 
 853 If the colon (\fB:\fR ) is omitted from the expression, the shell only checks
 854 whether \fIparameter\fR is set or not.
 855 .RE
 856 
 857 .sp
 858 .ne 2
 859 .na
 860 \fB\fB${\fR\fIparameter\fR\fB:+\fR\fIword\fR\fB}\fR\fR
 861 .ad
 862 .sp .6
 863 .RS 4n
 864 If \fIparameter\fR is set and is non-null, substitute \fIword\fR. Otherwise
 865 substitute nothing.
 866 .sp
 867 \fIword\fR is not evaluated unless it is to be used as the substituted string.
 868 .sp
 869 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
 870 is NULL:
 871 .sp
 872 .in +2
 873 .nf
 874 print ${d:-$(pwd)}
 875 .fi
 876 .in -2
 877 .sp
 878 
 879 If the colon (\fB:\fR) is omitted from the expression, the shell only checks
 880 whether \fIparameter\fR is set or not.
 881 .RE
 882 
 883 .sp
 884 .ne 2
 885 .na
 886 \fB\fB${\fR\fIparameter\fR\fB:\fR\fIoffset\fR:\fIlength\fR}\fR
 887 .ad
 888 .br
 889 .na
 890 \fB\fB${\fR\fIparameter\fR\fB:\fR\fIoffset\fR\fB}\fR\fR
 891 .ad
 892 .sp .6
 893 .RS 4n
 894 Expands to the portion of the value of \fIparameter\fR starting at the
 895 character (counting from \fB0\fR) determined by expanding offset as an
 896 arithmetic expression and consisting of the number of characters determined by
 897 the arithmetic expression defined by \fIlength\fR.
 898 .sp
 899 In the second form, the remainder of the value is used. A negative offset
 900 counts backwards from the end of \fIparameter\fR.
 901 .sp
 902 One or more BLANKs is required in front of a minus sign to prevent the shell
 903 from interpreting the operator as \fB:-\fR. If parameter is \fB*\fR or \fB@\fR,
 904 or is an array name indexed by \fB*\fR or \fB@\fR, then \fIoffset\fR and
 905 \fIlength\fR refer to the array index and number of elements respectively. A
 906 negative \fIoffset\fR is taken relative to one greater than the highest
 907 subscript for indexed arrays. The order for associative arrays is unspecified.
 908 .RE
 909 
 910 .sp
 911 .ne 2
 912 .na
 913 \fB\fB${\fR\fIparameter\fR\fB#\fR\fIpattern\fR\fB}\fR\fR
 914 .ad
 915 .br
 916 .na
 917 \fB\fB${\fR\fIparameter\fR\fB##\fR\fIpattern\fR\fB}\fR\fR
 918 .ad
 919 .sp .6
 920 .RS 4n
 921 If the shell \fIpattern\fR matches the beginning of the value of
 922 \fIparameter\fR, then the value of this expansion is the value of the
 923 \fIparameter\fR with the matched portion deleted. Otherwise the value of this
 924 \fIparameter\fR is substituted. In the first form the smallest matching
 925 \fIpattern\fR is deleted and in the second form the largest matching
 926 \fIpattern\fR is deleted. When \fIparameter\fR is \fB@\fR, \fB*\fR, or an array
 927 variable with subscript \fB@\fR or \fB*\fR, the substring operation is applied
 928 to each element in turn.
 929 .RE
 930 
 931 .sp
 932 .ne 2
 933 .na
 934 \fB\fB${\fR\fIparameter\fR\fB%\fR\fIpattern\fR\fB}\fR\fR
 935 .ad
 936 .br
 937 .na
 938 \fB\fB${\fR\fIparameter\fR\fB%%\fR\fIpattern\fR\fB}\fR\fR
 939 .ad
 940 .sp .6
 941 .RS 4n
 942 If the shell \fIpattern\fR matches the end of the value of \fIparameter\fR,
 943 then the value of this expansion is the value of the parameter with the matched
 944 part deleted. Otherwise substitute the value of \fIparameter\fR. In the first
 945 form the smallest matching pattern is deleted, and in the second form the
 946 largest matching pattern is deleted. When parameter is \fB@\fR, \fB*\fR, or an
 947 array variable with subscript \fB@\fR or \fB*\fR, the substring operation is
 948 applied to each element in turn.
 949 .RE
 950 
 951 .sp
 952 .ne 2
 953 .na
 954 \fB\fB${\fR\fIparameter\fR\fB/\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
 955 .ad
 956 .br
 957 .na
 958 \fB\fB${\fR\fIparameter\fR\fB//\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
 959 .ad
 960 .br
 961 .na
 962 \fB\fB${\fR\fIparameter\fR\fB/#\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
 963 .ad
 964 .br
 965 .na
 966 \fB\fB${\fR\fIparameter\fR\fB/%\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
 967 .ad
 968 .sp .6
 969 .RS 4n
 970 Expands \fIparameter\fR and replaces the longest match of \fIpattern\fR with
 971 the specified \fIstring\fR. Each occurrence of \fB\e\fR\fIn\fR in \fIstring\fR
 972 is replaced by the portion of \fIparameter\fR that matches the \fIn\fR\fBth\fR
 973 sub-pattern.
 974 .sp
 975 When \fIstring\fR is null, the \fIpattern\fR is deleted and the \fB/\fR in
 976 front of string can be omitted. When \fIparameter\fR is \fB@\fR, \fB*\fR, or an
 977 array variable with subscript \fB@\fR or \fB*\fR, the substitution operation is
 978 applied to each element in turn. In this case, the \fIstring\fR portion of
 979 \fIword\fR is re-evaluated for each element.
 980 .sp
 981 In the first form, only the first occurrence of \fIpattern\fR is replaced.
 982 .sp
 983 In the second form, each match for \fIpattern\fR is replaced by the specified
 984 \fIstring\fR.
 985 .sp
 986 The third form restricts the pattern match to the beginning of the
 987 \fIstring\fR.
 988 .sp
 989 The fourth form restricts the pattern match to the end of the \fIstring\fR.
 990 .RE
 991 
 992 .sp
 993 .LP
 994 The following parameters are automatically set by the shell:
 995 .sp
 996 .ne 2
 997 .na
 998 \fB\fB#\fR\fR
 999 .ad
1000 .RS 19n
1001 The number of positional parameters in decimal.
1002 .RE
1003 
1004 .sp
1005 .ne 2
1006 .na
1007 \fB\fB-\fR\fR
1008 .ad
1009 .RS 19n
1010 Options supplied to the shell on invocation or by the \fBset\fR command.
1011 .RE
1012 
1013 .sp
1014 .ne 2
1015 .na
1016 \fB\fB?\fR\fR
1017 .ad
1018 .RS 19n
1019 The decimal value returned by the last executed command.
1020 .RE
1021 
1022 .sp
1023 .ne 2
1024 .na
1025 \fB\fB$\fR\fR
1026 .ad
1027 .RS 19n
1028 The process number of this shell.
1029 .RE
1030 
1031 .sp
1032 .ne 2
1033 .na
1034 \fB\fB_\fR\fR
1035 .ad
1036 .RS 19n
1037 Initially, the value of \fB_\fR is the absolute pathname of the shell or script
1038 being executed as passed in the environment. It is subsequently assigned the
1039 last argument of the previous command.
1040 .sp
1041 This parameter is not set for commands which are asynchronous. This parameter
1042 is also used to hold the name of the matching \fBMAIL\fR file when checking for
1043 mail.
1044 .RE
1045 
1046 .sp
1047 .ne 2
1048 .na
1049 \fB\fB!\fR\fR
1050 .ad
1051 .RS 19n
1052 The process number of the last background command invoked or the most recent
1053 job put in the background with the \fBbg\fR built-in command.
1054 .RE
1055 
1056 .sp
1057 .ne 2
1058 .na
1059 \fB\fB\&.sh.command\fR\fR
1060 .ad
1061 .RS 19n
1062 When processing a \fBDEBUG\fR trap, this variable contains the current command
1063 line that is about to run.
1064 .RE
1065 
1066 .sp
1067 .ne 2
1068 .na
1069 \fB\fB\&.sh.edchar\fR\fR
1070 .ad
1071 .RS 19n
1072 This variable contains the value of the keyboard character (or sequence of
1073 characters if the first character is an ESC, \fBASCII 033\fR) that has been
1074 entered when processing a \fBKEYBD\fR trap. If the value is changed as part of
1075 the trap action, then the new value replaces the key (or key sequence) that
1076 caused the trap. See the \fBKey Bindings\fR section of this manual page.
1077 .RE
1078 
1079 .sp
1080 .ne 2
1081 .na
1082 \fB\fB\&.sh.edcol\fR\fR
1083 .ad
1084 .RS 19n
1085 The character position of the cursor at the time of the most recent \fBKEYBD\fR
1086 trap.
1087 .RE
1088 
1089 .sp
1090 .ne 2
1091 .na
1092 \fB\fB\&.sh.edmode\fR\fR
1093 .ad
1094 .RS 19n
1095 The value is set to ESC when processing a \fBKEYBD\fR trap while in \fBvi\fR
1096 insert mode. Otherwise, \fB\&.sh.edmode\fR is null when processing a
1097 \fBKEYBD\fR trap. See the \fBvi Editing Mode\fR section of this manual page.
1098 .RE
1099 
1100 .sp
1101 .ne 2
1102 .na
1103 \fB\fB\&.sh.edtext\fR\fR
1104 .ad
1105 .RS 19n
1106 The characters in the input buffer at the time of the most recent \fBKEYBD\fR
1107 trap. The value is null when not processing a \fBKEYBD\fR trap.
1108 .RE
1109 
1110 .sp
1111 .ne 2
1112 .na
1113 \fB\fB\&.sh.file\fR\fR
1114 .ad
1115 .RS 19n
1116 The pathname of the file than contains the current command.
1117 .RE
1118 
1119 .sp
1120 .ne 2
1121 .na
1122 \fB\fB\&.sh.fun\fR\fR
1123 .ad
1124 .RS 19n
1125 The name of the current function that is being executed.
1126 .RE
1127 
1128 .sp
1129 .ne 2
1130 .na
1131 \fB\fB\&.sh.match\fR\fR
1132 .ad
1133 .RS 19n
1134 An indexed array which stores the most recent match and sub-pattern matches
1135 after conditional pattern matches that match and after variables expansions
1136 using the operators \fB#\fR, \fB%\fR, or \fB/\fR. The \fB0\fRth element stores
1137 the complete match and the \fIi\fRth element stores the \fIi\fRth sub-match.
1138 The \fB\&.sh.match\fR variable is unset when the variable that has expanded is
1139 assigned a new value.
1140 .RE
1141 
1142 .sp
1143 .ne 2
1144 .na
1145 \fB\fB\&.sh.name\fR\fR
1146 .ad
1147 .RS 19n
1148 Set to the name of the variable at the time that a discipline function is
1149 invoked.
1150 .RE
1151 
1152 .sp
1153 .ne 2
1154 .na
1155 \fB\fB\&.sh.subscript\fR\fR
1156 .ad
1157 .RS 19n
1158 Set to the name subscript of the variable at the time that a discipline
1159 function is invoked.
1160 .RE
1161 
1162 .sp
1163 .ne 2
1164 .na
1165 \fB\fB\&.sh.subshell\fR\fR
1166 .ad
1167 .RS 19n
1168 The current depth for sub-shells and command substitution.
1169 .RE
1170 
1171 .sp
1172 .ne 2
1173 .na
1174 \fB\fB\&.sh.value\fR\fR
1175 .ad
1176 .RS 19n
1177 Set to the value of the variable at the time that the set or append discipline
1178 function is invoked.
1179 .RE
1180 
1181 .sp
1182 .ne 2
1183 .na
1184 \fB\fB\&.sh.version\fR\fR
1185 .ad
1186 .RS 19n
1187 Set to a value that identifies the version of this shell.
1188 .RE
1189 
1190 .sp
1191 .ne 2
1192 .na
1193 \fB\fBLINENO\fR\fR
1194 .ad
1195 .RS 19n
1196 The current line number within the script or function being executed.
1197 .RE
1198 
1199 .sp
1200 .ne 2
1201 .na
1202 \fB\fBOLDPWD\fR\fR
1203 .ad
1204 .RS 19n
1205 The previous working directory set by the \fBcd\fR command.
1206 .RE
1207 
1208 .sp
1209 .ne 2
1210 .na
1211 \fB\fBOPTARG\fR\fR
1212 .ad
1213 .RS 19n
1214 The value of the last option argument processed by the \fBgetopts\fR built-in
1215 command.
1216 .RE
1217 
1218 .sp
1219 .ne 2
1220 .na
1221 \fB\fBOPTIND\fR\fR
1222 .ad
1223 .RS 19n
1224 The index of the last option argument processed by the \fBgetopts\fR built-in
1225 command.
1226 .RE
1227 
1228 .sp
1229 .ne 2
1230 .na
1231 \fB\fBPPID\fR\fR
1232 .ad
1233 .RS 19n
1234 The process number of the parent of the shell.
1235 .RE
1236 
1237 .sp
1238 .ne 2
1239 .na
1240 \fB\fBPWD\fR\fR
1241 .ad
1242 .RS 19n
1243 The present working directory set by the \fBcd\fR command.
1244 .RE
1245 
1246 .sp
1247 .ne 2
1248 .na
1249 \fB\fBRANDOM\fR\fR
1250 .ad
1251 .RS 19n
1252 Each time this variable is referenced, a random integer, uniformly distributed
1253 between \fB0\fR and \fB32767\fR, is generated. The sequence of random numbers
1254 can be initialized by assigning a numeric value to \fBRANDOM\fR.
1255 .RE
1256 
1257 .sp
1258 .ne 2
1259 .na
1260 \fB\fBREPLY\fR\fR
1261 .ad
1262 .RS 19n
1263 This variable is set by the \fBselect\fR statement and by the \fBread\fR
1264 built-in command when no arguments are supplied.
1265 .RE
1266 
1267 .sp
1268 .ne 2
1269 .na
1270 \fB\fBSECONDS\fR\fR
1271 .ad
1272 .RS 19n
1273 Each time this variable is referenced, the number of seconds since shell
1274 invocation is returned. If this variable is assigned a value, then the value
1275 returned upon reference is the value that was assigned plus the number of
1276 seconds since the assignment.
1277 .RE
1278 
1279 .sp
1280 .LP
1281 The following variables are used by the shell:
1282 .sp
1283 .ne 2
1284 .na
1285 \fB\fBCDPATH\fR\fR
1286 .ad
1287 .RS 14n
1288 Defines the search path for the \fBcd\fR command.
1289 .RE
1290 
1291 .sp
1292 .ne 2
1293 .na
1294 \fB\fBCOLUMNS\fR\fR
1295 .ad
1296 .RS 14n
1297 Defines the width of the edit window for the shell edit modes and for printing
1298 select lists.
1299 .RE
1300 
1301 .sp
1302 .ne 2
1303 .na
1304 \fB\fBEDITOR\fR\fR
1305 .ad
1306 .RS 14n
1307 If the \fBVISUAL\fR variable is not set, the value of this variable is checked
1308 for the patterns as described with \fBVISUAL\fR and the corresponding editing
1309 option is turned on.
1310 .sp
1311 See the \fBset\fR command in the \fBSpecial Command\fR section of this manual
1312 page.
1313 .RE
1314 
1315 .sp
1316 .ne 2
1317 .na
1318 \fB\fBENV\fR\fR
1319 .ad
1320 .RS 14n
1321 Performs parameter expansion, command substitution, and arithmetic substitution
1322 on the value to generate the pathname of the script that is executed when the
1323 shell is invoked. This file is typically used for alias and function
1324 definitions. The default value is \fB$HOME/.kshrc\fR.
1325 .sp
1326 See the \fBInvocation\fR section of this manual page.
1327 .sp
1328 \fBENV\fR is not set by the shell.
1329 .RE
1330 
1331 .sp
1332 .ne 2
1333 .na
1334 \fB\fBFCEDIT\fR\fR
1335 .ad
1336 .RS 14n
1337 Obsolete name for the default editor name for the \fBhist\fR command.
1338 \fBFCEDIT\fR is not used when \fBHISTEDIT\fR is set.
1339 .sp
1340 The shell specifies a default value to \fBFCEDIT\fR.
1341 .RE
1342 
1343 .sp
1344 .ne 2
1345 .na
1346 \fB\fBFIGNORE\fR\fR
1347 .ad
1348 .RS 14n
1349 A pattern that defines the set of file names that is ignored when performing
1350 file name matching.
1351 .RE
1352 
1353 .sp
1354 .ne 2
1355 .na
1356 \fB\fBFPATH\fR\fR
1357 .ad
1358 .RS 14n
1359 The search path for function definitions. The directories in this path are
1360 searched for a file with the same name as the function or command when a
1361 function with the \fB-u\fR attribute is referenced and when a command is not
1362 found. If an executable file with the name of that command is found, then it is
1363 read and executed in the current environment. Unlike \fBPATH\fR, the current
1364 directory must be represented explicitly by dot (\fB\&.\fR) rather than by
1365 adjacent colon (\fB:\fR) characters or a beginning or ending colon (\fB:\fR).
1366 .RE
1367 
1368 .sp
1369 .ne 2
1370 .na
1371 \fB\fBHISTCMD\fR\fR
1372 .ad
1373 .RS 14n
1374 The number of the current command in the history file.
1375 .RE
1376 
1377 .sp
1378 .ne 2
1379 .na
1380 \fB\fBHISTEDIT\fR\fR
1381 .ad
1382 .RS 14n
1383 The name for the default editor name for the \fBhist\fR command.
1384 .RE
1385 
1386 .sp
1387 .ne 2
1388 .na
1389 \fB\fBHISTFILE\fR\fR
1390 .ad
1391 .RS 14n
1392 If this variable is set when the shell is invoked, the value is the pathname of
1393 the file that is used to store the command history. See the \fBCommand
1394 Re-entry\fR section of this manual page.
1395 .RE
1396 
1397 .sp
1398 .ne 2
1399 .na
1400 \fB\fBHISTSIZE\fR\fR
1401 .ad
1402 .RS 14n
1403 If this variable is set when the shell is invoked, then the number of
1404 previously entered commands that are accessible by this shell is greater than
1405 or equal to this number. The default is \fB512\fR.
1406 .RE
1407 
1408 .sp
1409 .ne 2
1410 .na
1411 \fB\fBHOME\fR\fR
1412 .ad
1413 .RS 14n
1414 The default argument (home directory) for the \fBcd\fR command.
1415 .sp
1416 \fBHOME\fR is not set by the shell. \fBHOME\fR is set by \fBlogin\fR(1).
1417 .RE
1418 
1419 .sp
1420 .ne 2
1421 .na
1422 \fB\fBIFS\fR\fR
1423 .ad
1424 .RS 14n
1425 Internal field separators, normally SPACE, TAB, and NEWLINE that are used to
1426 separate the results of command substitution or parameter expansion and to
1427 separate fields with the built-in command read. The first character of the
1428 \fBIFS\fR variable is used to separate arguments for the \fB"$*"\fR
1429 substitution. See the \fBQuoting\fR section of this manual page.
1430 .sp
1431 Each single occurrence of an \fBIFS\fR character in the string to be split,
1432 that is not in the \fBissspace\fR character class, and any adjacent characters
1433 in \fBIFS\fR that are in the \fBissspace\fR character class, delimit a field.
1434 One or more characters in IFS that belong to the \fBissspace\fR character
1435 class, delimit a field. In addition, if the same \fBissspace\fR character
1436 appears consecutively inside \fBIFS\fR, this character is treated as if it were
1437 not in the \fBissspace\fR class, so that if \fBIFS\fR consists of two tab
1438 characters, then two adjacent tab characters delimit a null field.
1439 .sp
1440 The shell specifies a default value to \fBIFS\fR.
1441 .RE
1442 
1443 .sp
1444 .ne 2
1445 .na
1446 \fB\fBLANG\fR\fR
1447 .ad
1448 .RS 14n
1449 This variable determines the locale category for any category not specifically
1450 selected with a variable starting with \fBLC_\fR or \fBLANG\fR.
1451 .RE
1452 
1453 .sp
1454 .ne 2
1455 .na
1456 \fB\fBLC_ALL\fR\fR
1457 .ad
1458 .RS 14n
1459 This variable overrides the value of the \fBLANG\fR variable and any other
1460 \fBLC_\fR variable.
1461 .RE
1462 
1463 .sp
1464 .ne 2
1465 .na
1466 \fB\fBLC_COLLATE\fR\fR
1467 .ad
1468 .RS 14n
1469 This variable determines the locale category for character collation
1470 information.
1471 .RE
1472 
1473 .sp
1474 .ne 2
1475 .na
1476 \fB\fBLC_CTYPE\fR\fR
1477 .ad
1478 .RS 14n
1479 This variable determines the locale category for character handling functions.
1480 It determines the character classes for pattern matching. See the \fBFile Name
1481 Generation\fR section of this manual page.
1482 .RE
1483 
1484 .sp
1485 .ne 2
1486 .na
1487 \fB\fBLC_NUMERIC\fR\fR
1488 .ad
1489 .RS 14n
1490 This variable determines the locale category for the decimal point character.
1491 .RE
1492 
1493 .sp
1494 .ne 2
1495 .na
1496 \fB\fBLINES\fR\fR
1497 .ad
1498 .RS 14n
1499 If this variable is set, the value is used to determine the column length for
1500 printing select lists. Select lists prints vertically until about two-thirds of
1501 \fBLINES\fR lines are filled.
1502 .RE
1503 
1504 .sp
1505 .ne 2
1506 .na
1507 \fB\fBMAIL\fR\fR
1508 .ad
1509 .RS 14n
1510 If this variable is set to the name of a mail file \fBand\fR the \fBMAILPATH\fR
1511 variable is not set, then the shell informs the user of arrival of mail in the
1512 specified file.
1513 .sp
1514 \fBMAIL\fR is not set by the shell. On some systems, \fBMAIL\fR is set by
1515 \fBlogin\fR(1).
1516 .RE
1517 
1518 .sp
1519 .ne 2
1520 .na
1521 \fB\fBMAILCHECK\fR\fR
1522 .ad
1523 .RS 14n
1524 Specifies how often in seconds the shell checks for changes in the modification
1525 time of any of the files specified by the \fBMAILPATH\fR or \fBMAIL\fR
1526 variables. The default value is \fB600\fR seconds. When the time has elapsed
1527 the shell checks before issuing the next prompt.
1528 .sp
1529 The shell specifies a default value to \fBMAILCHECK\fR.
1530 .RE
1531 
1532 .sp
1533 .ne 2
1534 .na
1535 \fB\fBMAILPATH\fR\fR
1536 .ad
1537 .RS 14n
1538 A colon ( \fB:\fR ) separated list of file names. If this variable is set, then
1539 the shell informs the user of any modifications to the specified files that
1540 have occurred within the last \fBMAILCHECK\fR seconds. Each file name can be
1541 followed by a \fB?\fR and a message that is printed. The message undergoes
1542 parameter expansion, command substitution, and arithmetic substitution with the
1543 variable \fB$_\fR defined as the name of the file that has changed. The default
1544 message is \fByou have mail in $_\fR.
1545 .RE
1546 
1547 .sp
1548 .ne 2
1549 .na
1550 \fB\fBPATH\fR\fR
1551 .ad
1552 .RS 14n
1553 The search path for commands. Except in \fB\&.profile\fR, users cannot change
1554 \fBPATH\fR if executing under \fBrksh93\fR. See the \fBExecution\fR section of
1555 this manual page.
1556 .sp
1557 The shell specifies a default value to \fBPATH\fR.
1558 .RE
1559 
1560 .sp
1561 .ne 2
1562 .na
1563 \fB\fBPS1\fR\fR
1564 .ad
1565 .RS 14n
1566 The value of this variable is expanded for parameter expansion, command
1567 substitution, and arithmetic substitution to define the primary prompt string
1568 which by default is \fB$\fR. The character \fB!\fR in the primary prompt string
1569 is replaced by the command number. Two successive occurrences of \fB!\fR
1570 produces a single \fB!\fR when the prompt string is printed. See the \fBCommand
1571 Re-entry\fR section of this manual page.
1572 .sp
1573 The shell specifies a default value to \fBPS1\fR.
1574 .RE
1575 
1576 .sp
1577 .ne 2
1578 .na
1579 \fB\fBPS2\fR\fR
1580 .ad
1581 .RS 14n
1582 Secondary prompt string, by default, \fB>\fR.
1583 .sp
1584 The shell specifies a default value to \fBPS2\fR.
1585 .RE
1586 
1587 .sp
1588 .ne 2
1589 .na
1590 \fB\fBPS3\fR\fR
1591 .ad
1592 .RS 14n
1593 Selection prompt string used within a select loop, by default \fB#?\fR.
1594 .sp
1595 The shell specifies a default value to \fBPS3\fR.
1596 .RE
1597 
1598 .sp
1599 .ne 2
1600 .na
1601 \fB\fBPS4\fR\fR
1602 .ad
1603 .RS 14n
1604 The value of this variable is expanded for parameter evaluation, command
1605 substitution, and arithmetic substitution and precedes each line of an
1606 execution trace. By default, \fBPS4\fR is \fB+\fR. When \fBPS4\fR is unset, the
1607 execution trace prompt is also \fB+\fR .
1608 .sp
1609 The shell specifies a default value to \fBPS4\fR.
1610 .RE
1611 
1612 .sp
1613 .ne 2
1614 .na
1615 \fB\fBSHELL\fR\fR
1616 .ad
1617 .RS 14n
1618 The pathname of the shell is kept in the environment. At invocation, if the
1619 basename of this variable is \fBrsh\fR, \fBrksh\fR, \fBrksh93\fR, or
1620 \fBkrsh\fR, the shell becomes restricted.
1621 .sp
1622 \fBSHELL\fR is not set by the shell. On some systems, \fBSHELL\fR is set by
1623 \fBlogin\fR(1).
1624 .RE
1625 
1626 .sp
1627 .ne 2
1628 .na
1629 \fB\fBTIMEFORMAT\fR\fR
1630 .ad
1631 .RS 14n
1632 The value of this parameter is used as a format string specifying how the
1633 timing information for pipelines prefixed with the \fBtime\fR reserved word
1634 should be displayed. The \fB%\fR character introduces a format sequence that is
1635 expanded to a time value or other information.
1636 .sp
1637 The format sequences and their meanings are as follows.
1638 .sp
1639 .ne 2
1640 .na
1641 \fB\fB%%\fR\fR
1642 .ad
1643 .sp .6
1644 .RS 4n
1645 A literal \fB%\fR.
1646 .RE
1647 
1648 .sp
1649 .ne 2
1650 .na
1651 \fB\fB%[\fIp\fR][l]R\fR\fR
1652 .ad
1653 .sp .6
1654 .RS 4n
1655 The elapsed time in seconds.
1656 .RE
1657 
1658 .sp
1659 .ne 2
1660 .na
1661 \fB\fB%[\fIp\fR][l]U\fR\fR
1662 .ad
1663 .sp .6
1664 .RS 4n
1665 The number of CPU seconds spent in user mode.
1666 .RE
1667 
1668 .sp
1669 .ne 2
1670 .na
1671 \fB\fB%[\fIp\fR][l]S\fR\fR
1672 .ad
1673 .sp .6
1674 .RS 4n
1675 The number of CPU seconds spent in system mode.
1676 .RE
1677 
1678 .sp
1679 .ne 2
1680 .na
1681 \fB\fB%P\fR\fR
1682 .ad
1683 .sp .6
1684 .RS 4n
1685 The CPU percentage, computed as \fB(U + S) / R\fR.
1686 .RE
1687 
1688 The braces denote optional portions. The optional \fIp\fR is a digit specifying
1689 the \fIprecision\fR, the number of fractional digits after a decimal point. A
1690 value of \fB0\fR causes no decimal point or fraction to be output. At most
1691 three places after the decimal point can be displayed. Values of \fIp\fR
1692 greater than \fB3\fR are treated as \fB3\fR. If \fIp\fR is not specified, the
1693 value \fB3\fR is used.
1694 .sp
1695 The optional \fBl\fR specifies a longer format, including hours if greater than
1696 zero, minutes, and seconds of the form \fIHHhMMmSS.FFs\fR. The value of \fIp\fR
1697 determines whether or not the fraction is included.
1698 .sp
1699 All other characters are output without change and a trailing NEWLINE is added.
1700 If unset, the default value, \fB$'\enreal\t%2lR\nuser\t%2lU\nsys%2lS'\fR, is
1701 used. If the value is null, no timing information is displayed.
1702 .RE
1703 
1704 .sp
1705 .ne 2
1706 .na
1707 \fB\fBTMOUT\fR\fR
1708 .ad
1709 .RS 14n
1710 If set to a value greater than zero, \fBTMOUT\fR is the default time-out value
1711 for the \fBread\fR built-in command. The \fBselect\fR compound command
1712 terminates after \fBTMOUT\fR seconds when input is from a terminal. Otherwise,
1713 the shell terminates if a line is not entered within the prescribed number of
1714 seconds while reading from a terminal. The shell can be compiled with a maximum
1715 bound for this value which cannot be exceeded.
1716 .sp
1717 The shell specifies a default value to \fBTMOUT\fR.
1718 .RE
1719 
1720 .sp
1721 .ne 2
1722 .na
1723 \fB\fBVISUAL\fR\fR
1724 .ad
1725 .RS 14n
1726 If the value of this variable matches the pattern \fB*[Vv][Ii]*\fR, then the
1727 \fBvi\fR option is turned on. See \fBSpecial Commands\fR. If the value matches
1728 the pattern \fB*gmacs*\fR , the \fBgmacs\fR option is turned on. If the value
1729 matches the pattern \fB*macs*\fR, then the \fBemacs\fR option is turned on. The
1730 value of \fBVISUAL\fR overrides the value of \fBEDITOR\fR.
1731 .RE
1732 
1733 .SS "Field Splitting"
1734 .sp
1735 .LP
1736 After parameter expansion and command substitution, the results of
1737 substitutions are scanned for the field separator characters (those found in
1738 \fBIFS\fR) and split into distinct fields where such characters are found.
1739 Explicit null fields (\fB""\fR or \fB\&''\fR) are retained. Implicit null
1740 fields, those resulting from parameters that have no values or command
1741 substitutions with no output, are removed.
1742 .sp
1743 .LP
1744 If the \fBbraceexpand\fR (\fB-B\fR) option is set, each of the fields resulting
1745 from \fBIFS\fR are checked to see if they contain one or more of the brace
1746 patterns. Valid brace patterns: \fB{*\fR,\fB*}\fR,
1747 \fB{\fR\fIl1\fR\fB\&..\fR\fIl2\fR\fB}\fR ,
1748 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR\fB}\fR,
1749 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR\fB%\fR\fIfmt\fR\fB}
1750 {\fR\fIn1\fR\fB\&..\fR\fIn2\fR \fB\&..\fR\fIn3\fR\fB}\fR, or
1751 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR \fB\&..\fR\fIn3\fR\fB%\fR\fIfmt\fR\fB}\fR ,
1752 where \fB*\fR represents any character, \fIl1\fR,\fIl2\fR are letters and
1753 \fIn1\fR,\fIn2\fR,\fIn3\fR are signed numbers and \fIfmt\fR is a format
1754 specified as used by \fBprintf\fR. In each case, fields are created by
1755 prepending the characters before the \fB{\fR and appending the characters after
1756 the } to each of the strings generated by the characters between the \fB{\fR
1757 and \fB}\fR. The resulting fields are checked to see if they have any brace
1758 patterns.
1759 .sp
1760 .LP
1761 In the first form, a field is created for each string between \fB{\fR and
1762 \fB,,\fR between \fB,\fR and \fB,,\fR and between , and \fB}\fR. The string
1763 represented by \fB*\fR can contain embedded matching { and } without quoting.
1764 Otherwise, each \fB{\fR and \fB}\fR with \fB*\fR must be quoted.
1765 .sp
1766 .LP
1767 In the second form, \fIl1\fR and \fIl2\fR must both be either upper case or
1768 both be lower case characters in the C locale. In this case a field is created
1769 for each character from \fIl1\fR through \fIl2\fR.
1770 .sp
1771 .LP
1772 In the remaining forms, a field is created for each number starting at
1773 \fIn1\fR. This continues until it reaches \fIn2\fR and increments \fIn1\fR by
1774 \fIn3\fR. The cases where \fIn3\fR is not specified behave as if \fIn3\fR were
1775 1 if \fIn1\fR\fB<=\fR\fIn2\fR, and \fB-1\fR otherwise. In forms which specify
1776 \fB%\fR\fIfmt\fR, any format flags, widths and precisions can be specified and
1777 \fIfmt\fR can end in any of the specifiers \fBcdiouxX\fR. For example,
1778 \fB{a,z}{1..5..3%02d}{b..c}x\fR expands to the 8 fields, \fBa01bx, a01cx,
1779 a04bx, a04cx, z01bx, z01cx, z04bx,\fR and \fBz4cx\fR.
1780 .SS "File Name Generation"
1781 .sp
1782 .LP
1783 Following splitting, each field is scanned for the characters \fB*\fR, \fB?\fR,
1784 \fB(\fR, and \fB[\fR, unless the \fB-f\fR option has been set. If one of these
1785 characters appears, then the word is regarded as a pattern.
1786 .sp
1787 .LP
1788 Each file name component that contains any pattern character is replaced with a
1789 lexicographically sorted set of names that matches the pattern from that
1790 directory. If no file name is found that matches the pattern, then that
1791 component of the file name is left unchanged unless the pattern is prefixed
1792 with \fB~(N)\fR in which case it is removed. If \fBFIGNORE\fR is set, then each
1793 file name component that matches the pattern defined by the value of
1794 \fBFIGNORE\fR is ignored when generating the matching file names. The names
1795 \fB\&.\fR and \fB\&..\fR are also ignored. If \fBFIGNORE\fR is not set, the
1796 character \fB\&.\fR at the start of each file name component is ignored unless
1797 the first character of the pattern corresponding to this component is the
1798 character \fB\&.\fR itself. For other uses of pattern matching the \fB/\fR and
1799 \fB\&.\fR are not specially treated.
1800 .sp
1801 .ne 2
1802 .na
1803 \fB\fB*\fR\fR
1804 .ad
1805 .RS 11n
1806 Match any string, including the null string. When used for file name expansion,
1807 if the \fBglobstar\fR option is on, two adjacent \fB*\fRs by themselves match
1808 all files and zero or more directories and subdirectories. If the two adjacent
1809 \fB*\fRs are followed by a \fB/\fR, only directories and subdirectories match.
1810 .RE
1811 
1812 .sp
1813 .ne 2
1814 .na
1815 \fB\fB?\fR\fR
1816 .ad
1817 .RS 11n
1818 Matches any single character.
1819 .RE
1820 
1821 .sp
1822 .ne 2
1823 .na
1824 \fB[\fB\&...\fR]\fR
1825 .ad
1826 .RS 11n
1827 Match any one of the enclosed characters. A pair of characters separated by
1828 \fB-\fR matches any character lexically between the pair, inclusive. If the
1829 first character following the opening \fB[\fR is a \fB!\fR, any character not
1830 enclosed is matched. A \fB-\fR can be included in the character set by putting
1831 it as the first or last character. Within \fB[\fR and \fB]\fR, character
1832 classes can be specified with the syntax \fB[:\fR\fIclass\fR\fB:]\fR where
1833 \fIclass\fR is one of the following classes defined in the \fBANSI-C\fR
1834 standard:
1835 .sp
1836 .in +2
1837 .nf
1838 \fIalnum alpha blank cntrl digit graph
1839 lower print punct space upper
1840 word xdigit\fR
1841 .fi
1842 .in -2
1843 .sp
1844 
1845 \fIword\fR is equivalent to \fIalnum\fR plus the character \fB_\fR. Within
1846 \fB[\fR and \fB]\fR, an equivalence class can be specified with the syntax
1847 \fB[=\fR\fIc\fR\fB=]\fR which matches all characters with the same primary
1848 collation weight (as defined by the current locale) as the character \fIc\fR.
1849 Within \fB[\fR and \fB]\fR, [\fI\&.symbol.\fR] matches the collating symbol
1850 \fIsymbol\fR.
1851 .RE
1852 
1853 .sp
1854 .LP
1855 A \fIpattern-list\fR is a list of one or more patterns separated from each
1856 other with an \fB&\fR or \fB|\fR. An \fB&\fR signifies that all patterns must
1857 be matched whereas \fB|\fR requires that only one pattern be matched. Composite
1858 patterns can be formed with one or more of the following sub-patterns:
1859 .sp
1860 .ne 2
1861 .na
1862 \fB\fB?(\fR\fIpattern-list\fR\fB)\fR\fR
1863 .ad
1864 .RS 22n
1865 Optionally matches any one of the specified patterns.
1866 .RE
1867 
1868 .sp
1869 .ne 2
1870 .na
1871 \fB\fB*(\fR\fIpattern-list\fR\fB)\fR\fR
1872 .ad
1873 .RS 22n
1874 Matches zero or more occurrences of the specified patterns.
1875 .RE
1876 
1877 .sp
1878 .ne 2
1879 .na
1880 \fB\fB+(\fR\fIpattern-list\fR\fB)\fR\fR
1881 .ad
1882 .RS 22n
1883 Matches one or more occurrences of the specified patterns.
1884 .RE
1885 
1886 .sp
1887 .ne 2
1888 .na
1889 \fB\fB{\fR\fIn\fR\fB(\fR\fIpattern-list\fR\fB)\fR\fR
1890 .ad
1891 .RS 22n
1892 Matches \fIn\fR occurrences of the specified patterns.
1893 .RE
1894 
1895 .sp
1896 .ne 2
1897 .na
1898 \fB\fB{\fR\fIm\fR\fB,\fR\fIn\fR\fB(\fR\fIpattern-list\fR\fB)\fR\fR
1899 .ad
1900 .RS 22n
1901 Matches from \fIm\fR to \fIn\fR occurrences of the specified patterns. If
1902 \fIm\fR is omitted, \fB0\fR is used. If \fIn\fR is omitted at least \fIm\fR
1903 occurrences are matched.
1904 .RE
1905 
1906 .sp
1907 .ne 2
1908 .na
1909 \fB\fB@(\fR\fIpattern-list\fR\fB)\fR\fR
1910 .ad
1911 .RS 22n
1912 Matches exactly one of the specified patterns.
1913 .RE
1914 
1915 .sp
1916 .ne 2
1917 .na
1918 \fB\fB!(\fR\fIpattern-list\fR\fB)\fR\fR
1919 .ad
1920 .RS 22n
1921 Matches anything except one of the specified patterns.
1922 .RE
1923 
1924 .sp
1925 .LP
1926 By default, each pattern, or sub-pattern matches the longest string possible
1927 consistent with generating the longest overall match. If more than one match is
1928 possible, the one starting closest to the beginning of the string is chosen.
1929 However, for each of the compound patterns a \fB-\fR can be inserted in front
1930 of the \fB(\fR to cause the shortest match to the specified \fIpattern-list\fR
1931 to be used.
1932 .sp
1933 .LP
1934 When \fIpattern-list\fR is contained within parentheses, the backslash
1935 character \fB\e\fR is treated specially even when inside a character class. All
1936 \fBANSI-C\fR character escapes are recognized and match the specified
1937 character. In addition the following escape sequences are recognized:
1938 .sp
1939 .ne 2
1940 .na
1941 \fB\fB\ed\fR\fR
1942 .ad
1943 .RS 7n
1944 Matches any character in the digit class.
1945 .RE
1946 
1947 .sp
1948 .ne 2
1949 .na
1950 \fB\fB\eD\fR\fR
1951 .ad
1952 .RS 7n
1953 Matches any character not in the digit class.
1954 .RE
1955 
1956 .sp
1957 .ne 2
1958 .na
1959 \fB\fB\es\fR\fR
1960 .ad
1961 .RS 7n
1962 Matches any character in the space class.
1963 .RE
1964 
1965 .sp
1966 .ne 2
1967 .na
1968 \fB\fB\eS\fR\fR
1969 .ad
1970 .RS 7n
1971 Matches any character not in the space class.
1972 .RE
1973 
1974 .sp
1975 .ne 2
1976 .na
1977 \fB\fB\ew\fR\fR
1978 .ad
1979 .RS 7n
1980 Matches any character in the word class.
1981 .RE
1982 
1983 .sp
1984 .ne 2
1985 .na
1986 \fB\fB\eW\fR\fR
1987 .ad
1988 .RS 7n
1989 Matches any character not in the word class.
1990 .RE
1991 
1992 .sp
1993 .LP
1994 A pattern of the form \fB%(\fR\fIpattern-pairs\fR\fB)\fR is a sub-pattern that
1995 can be used to match nested character expressions. Each \fIpattern-pair\fR is a
1996 two character sequence which cannot contain \fB&\fR or \fB|\fR. The first
1997 \fIpattern-pair\fR specifies the starting and ending characters for the match.
1998 Each subsequent \fIpattern-pair\fR represents the beginning and ending
1999 characters of a nested group that is skipped over when counting starting and
2000 ending character matches. The behavior is unspecified when the first character
2001 of a \fIpattern-pair\fR is alphanumeric except for the following:
2002 .sp
2003 .ne 2
2004 .na
2005 \fB\fBD\fR\fR
2006 .ad
2007 .RS 5n
2008 Causes the ending character to terminate the search for this pattern without
2009 finding a match.
2010 .RE
2011 
2012 .sp
2013 .ne 2
2014 .na
2015 \fB\fBE\fR\fR
2016 .ad
2017 .RS 5n
2018 Causes the ending character to be interpreted as an escape character.
2019 .RE
2020 
2021 .sp
2022 .ne 2
2023 .na
2024 \fB\fBL\fR\fR
2025 .ad
2026 .RS 5n
2027 Causes the ending character to be interpreted as a quote character causing all
2028 characters to be ignored when looking for a match.
2029 .RE
2030 
2031 .sp
2032 .ne 2
2033 .na
2034 \fB\fBQ\fR\fR
2035 .ad
2036 .RS 5n
2037 Causes the ending character to be interpreted as a quote character causing all
2038 characters other than any escape character to be ignored when looking for a
2039 match.
2040 .RE
2041 
2042 .sp
2043 .LP
2044 \fB%({}Q"E\e)\fR, matches characters starting at \fB{\fR until the matching
2045 \fB}\fR is found not counting any \fB{\fR or \fB}\fR that is inside a double
2046 quoted string or preceded by the escape character \fB\e\fR\&. Without the
2047 \fB{}\fR this pattern matches any C language string.
2048 .sp
2049 .LP
2050 Each sub-pattern in a composite pattern is numbered, starting at \fB1\fR, by
2051 the location of the \fB(\fR within the pattern. The sequence \fB\e\fR\fIn\fR,
2052 where \fIn\fR is a single digit and \fB\e\fR\fIn\fR comes after the \fIn\fRth.
2053 sub-pattern, matches the same string as the sub-pattern itself.
2054 .sp
2055 .LP
2056 A pattern can contain sub-patterns of the form
2057 \fB~(\fR\fIoptions\fR\fB:\fR\fIpattern-list\fR\fB)\fR, where either
2058 \fIoptions\fR or \fB:\fR\fIpattern-list\fR can be omitted. Unlike the other
2059 compound patterns, these sub-patterns are not counted in the numbered
2060 sub-patterns. If \fIoptions\fR is present, it can consist of one or more of the
2061 following:
2062 .sp
2063 .ne 2
2064 .na
2065 \fB\fB+\fR\fR
2066 .ad
2067 .RS 5n
2068 Enable the following options. This is the default.
2069 .RE
2070 
2071 .sp
2072 .ne 2
2073 .na
2074 \fB\fB-\fR\fR
2075 .ad
2076 .RS 5n
2077 Disable the following options.
2078 .RE
2079 
2080 .sp
2081 .ne 2
2082 .na
2083 \fB\fBE\fR\fR
2084 .ad
2085 .RS 5n
2086 The remainder of the pattern uses extended regular expression syntax like the
2087 \fBegrep\fR(1) command.
2088 .RE
2089 
2090 .sp
2091 .ne 2
2092 .na
2093 \fB\fBF\fR\fR
2094 .ad
2095 .RS 5n
2096 The remainder of the pattern uses \fBfgrep\fR(1) expression syntax.
2097 .RE
2098 
2099 .sp
2100 .ne 2
2101 .na
2102 \fB\fBg\fR\fR
2103 .ad
2104 .RS 5n
2105 File the longest match (greedy).
2106 .sp
2107 This is the default.
2108 .RE
2109 
2110 .sp
2111 .ne 2
2112 .na
2113 \fB\fBG\fR\fR
2114 .ad
2115 .RS 5n
2116 The remainder of the pattern uses basic regular expression syntax like the
2117 \fBgrep\fR(1) command.
2118 .RE
2119 
2120 .sp
2121 .ne 2
2122 .na
2123 \fB\fBi\fR\fR
2124 .ad
2125 .RS 5n
2126 Treat the match as case insensitive.
2127 .RE
2128 
2129 .sp
2130 .ne 2
2131 .na
2132 \fB\fBK\fR\fR
2133 .ad
2134 .RS 5n
2135 The remainder of the pattern uses shell pattern syntax.
2136 .sp
2137 This is the default.
2138 .RE
2139 
2140 .sp
2141 .ne 2
2142 .na
2143 \fB\fBl\fR\fR
2144 .ad
2145 .RS 5n
2146 Left anchor the pattern.
2147 .sp
2148 This is the default for \fBK\fR style patterns.
2149 .RE
2150 
2151 .sp
2152 .ne 2
2153 .na
2154 \fB\fBN\fR\fR
2155 .ad
2156 .RS 5n
2157 This is ignored. However, when it is the first letter and is used with file
2158 name generation, and no matches occur, the file pattern expands to the empty
2159 string.
2160 .RE
2161 
2162 .sp
2163 .ne 2
2164 .na
2165 \fB\fBr\fR\fR
2166 .ad
2167 .RS 5n
2168 Right anchor the pattern.
2169 .sp
2170 This is the default for \fBK\fR style patterns.
2171 .RE
2172 
2173 .sp
2174 .LP
2175 If both \fIoptions\fR and \fB:\fR\fIpattern-list\fR are specified, then the
2176 options apply only to \fIpattern-list\fR. Otherwise, these options remain in
2177 effect until they are disabled by a subsequent \fB~(...)\fR or at the end of
2178 the sub-pattern containing \fB~(...)\fR.
2179 .SS "Quoting"
2180 .sp
2181 .LP
2182 Each of the metacharacters listed in the \fBDefinitions\fR has a special
2183 meaning to the shell.
2184 .sp
2185 .ne 2
2186 .na
2187 \fB\fBg\fR\fR
2188 .ad
2189 .RS 5n
2190 File the longest match (greedy). This is the default.
2191 .RE
2192 
2193 .sp
2194 .ne 2
2195 .na
2196 \fB\fBi\fR\fR
2197 .ad
2198 .RS 5n
2199 Treat the match as case insensitive.
2200 .RE
2201 
2202 .sp
2203 .LP
2204 If both \fIoptions\fR and \fB:\fR\fIpattern-list\fR are specified, then the
2205 options apply only to \fIpattern-list\fR. Otherwise, the options remain in
2206 effect until they are disabled by a subsequent \fB~(...)\fR or at the end of
2207 the sub-pattern containing \fB~(...)\fR.
2208 .sp
2209 .LP
2210 Each of the metacharacters listed in the \fBDefinitions\fR section of this
2211 manual page has a special meaning to the shell and causes termination of a word
2212 unless quoted. A character can be quoted, that is, made to stand for itself, by
2213 preceding it with a backslash (\fB\e\fR). The pair \fB\e\fRNEWLINE is removed.
2214 All characters enclosed between a pair of single quote marks (\fB\&''\fR) that
2215 is not preceded by a \fB$\fR are quoted. A single quote cannot appear within
2216 the single quotes. A single quoted string preceded by an unquoted \fB$\fR is
2217 processed as an \fBANSI-C\fR string except for the following:
2218 .sp
2219 .ne 2
2220 .na
2221 \fB\fB\e0\fR\fR
2222 .ad
2223 .RS 19n
2224 Causes the remainder of the string to be ignored.
2225 .RE
2226 
2227 .sp
2228 .ne 2
2229 .na
2230 \fB\fB\ec\fR\fIx\fR\fR
2231 .ad
2232 .RS 19n
2233 Expands to the character CTRL-x.
2234 .RE
2235 
2236 .sp
2237 .ne 2
2238 .na
2239 \fB\fB\eC\fR[\fB\&.\fR\fIname\fR\fB\&.\fR]\fR
2240 .ad
2241 .RS 19n
2242 Expands to the collating element \fIname\fR.
2243 .RE
2244 
2245 .sp
2246 .ne 2
2247 .na
2248 \fB\fB\ee\fR\fR
2249 .ad
2250 .RS 19n
2251 Equivalent to the escape character (\fBASCII\fR 033),
2252 .RE
2253 
2254 .sp
2255 .ne 2
2256 .na
2257 \fB\fB\eE\fR\fR
2258 .ad
2259 .RS 19n
2260 Equivalent to the escape character (\fBASCII\fR 033),
2261 .RE
2262 
2263 .sp
2264 .LP
2265 Inside double quote marks (\fB""\fR), parameter and command substitution occur
2266 and \fB\e\fR quotes the characters \fB\e\fR, \fB`\fR, \fB"\fR, and \fB$\fR. A
2267 \fB$\fR in front of a double quoted string is ignored in the \fBC\fR or
2268 \fBPOSIX\fR locale, and might cause the string to be replaced by a locale
2269 specific string otherwise. The meaning of \fB$*\fR and \fB$@\fR is identical
2270 when not quoted or when used as a variable assignment value or as a file name.
2271 However, when used as a command argument, \fB"$*"\fR is equivalent to
2272 \fB"$1\fId\fR$2\fId\fR..."\fR, where \fId\fR is the first character of the IFS
2273 variable, whereas \fB"$@"\fR is equivalent to \fB"$1" "$2" ....\fR Inside grave
2274 quote marks (\fB``\fR), \fB\\fR quotes the characters \fB\e\fR, \fB`\fR, and
2275 \fB$\fR. If the grave quotes occur within double quotes, then \fB\e\fR also
2276 quotes the character \fB"\fR.
2277 .sp
2278 .LP
2279 The special meaning of reserved words or aliases can be removed by quoting any
2280 character of the reserved word. The recognition of function names or built-in
2281 command names cannot be altered by quoting them.
2282 .SS "Arithmetic Evaluation"
2283 .sp
2284 .LP
2285 The shell performs arithmetic evaluation for arithmetic substitution, to
2286 evaluate an arithmetic command, to evaluate an indexed array subscript, and to
2287 evaluate arguments to the built-in commands \fBshift\fR and \fBlet\fR.
2288 Arithmetic evaluation is also performed on argument operands of the built-in
2289 command printf that correspond to numeric format specifiers in the format
2290 operand. See \fBprintf\fR(1). Evaluations are performed using double precision
2291 floating point arithmetic or long double precision floating point for systems
2292 that provide this data type. Floating point constants follow the \fBANSI-C\fR
2293 programming language floating point conventions. Integer constants follow the
2294 \fBANSI-C\fR programming language integer constant conventions although only
2295 single byte character constants are recognized and character casts are not
2296 recognized. Constants can be of the form \fB[\fR\fIbase#\fR\fB]\fR\fIn\fR where
2297 \fIbase\fR is a decimal number between two and sixty-four representing the
2298 arithmetic base and \fIn\fR is a number in that base. The digits greater than
2299 \fB9\fR are represented by the lower case letters, the upper case letters,
2300 \fB@\fR, and \fB_\fR respectively. For bases less than or equal to \fB36\fR,
2301 upper and lower case characters can be used interchangeably.
2302 .sp
2303 .LP
2304 An arithmetic expression uses the same syntax, precedence, and associativity of
2305 expression as the C language. All the C language operators that apply to
2306 floating point quantities can be used. In addition, the operator \fB**\fR can
2307 be used for exponentiation. It has higher precedence than multiplication and is
2308 left associative. When the value of an arithmetic variable or subexpression can
2309 be represented as a long integer, all C language integer arithmetic operations
2310 can be performed. Variables can be referenced by name within an arithmetic
2311 expression without using the parameter expansion syntax. When a variable is
2312 referenced, its value is evaluated as an arithmetic expression.
2313 .sp
2314 .LP
2315 Any of the following math library functions that are in the C math library can
2316 be used within an arithmetic expression:
2317 .sp
2318 .in +2
2319 .nf
2320 abs acos acosh asin asinh atan atan2 atanh cbrt
2321 copysign cos cosh erf erfc exp exp2 expm1 fabs
2322 fdim finite floor fma fmax fmod hypot ilogb
2323 int isinf isnan lgamma log log2 logb
2324 nearbyint nextafter nexttoward pow remainder
2325 rint round sin sinh sqrt tan tanh tgamma trunc
2326 .fi
2327 .in -2
2328 .sp
2329 
2330 .sp
2331 .LP
2332 An internal representation of a \fIvariable\fR as a double precision floating
2333 point can be specified with the \fB-E [\fR\fIn\fR\fB]\fR or \fB-F
2334 [\fR\fIn\fR\fB]\fR option of the \fBtypeset\fR special built-in command. The
2335 \fB-E\fR option causes the expansion of the value to be represented using
2336 scientific notation when it is expanded. The optional option argument \fIn\fR
2337 defines the number of significant figures. The \fB-F\fR option causes the
2338 expansion to be represented as a floating decimal number when it is expanded.
2339 The optional option argument \fIn\fR defines the number of places after the
2340 decimal point in this case.
2341 .sp
2342 .LP
2343 An internal integer representation of a \fIvariable\fR can be specified with
2344 the \fB-i\fR \fB[\fR\fIn\fR\fB]\fR option of the \fBtypeset\fR special built-in
2345 command. The optional option argument \fIn\fR specifies an arithmetic base to
2346 be used when expanding the variable. If you do not specify an arithmetic base,
2347 base 10 is used.
2348 .sp
2349 .LP
2350 Arithmetic evaluation is performed on the value of each assignment to a
2351 variable with the \fB-E\fR, \fB-F\fR, or \fB-i\fR option. Assigning a floating
2352 point number to a variable whose type is an integer causes the fractional part
2353 to be truncated.
2354 .SS "Prompting"
2355 .sp
2356 .LP
2357 When used interactively, the shell prompts with the value of \fBPS1\fR after
2358 expanding it for parameter expansion, command substitution, and arithmetic
2359 substitution, before reading a command. In addition, each single \fB!\fR in the
2360 prompt is replaced by the command number. A \fB!!\fR is required to place
2361 \fB!\fR in the prompt. If at any time a NEWLINE is typed and further input is
2362 needed to complete a command, then the secondary prompt, that is, the value of
2363 \fBPS2\fR, is issued.
2364 .SS "Conditional Expressions"
2365 .sp
2366 .LP
2367 A \fBconditional expression\fR is used with the \fB[[\fR compound command to
2368 test attributes of files and to compare strings. Field splitting and file name
2369 generation are not performed on the words between \fB[[\fR and \fB]]\fR.
2370 .sp
2371 .LP
2372 Each expression can be constructed from one or more of the following unary or
2373 binary expressions:
2374 .sp
2375 .ne 2
2376 .na
2377 \fB\fB-a\fR \fIfile\fR\fR
2378 .ad
2379 .RS 21n
2380 True, if \fIfile\fR exists.
2381 .sp
2382 This option is the same as \fB-e\fR. This option is obsolete.
2383 .RE
2384 
2385 .sp
2386 .ne 2
2387 .na
2388 \fB\fB-b\fR \fIfile\fR\fR
2389 .ad
2390 .RS 21n
2391 True, if \fIfile\fR exists and is a block special file.
2392 .RE
2393 
2394 .sp
2395 .ne 2
2396 .na
2397 \fB\fB-c\fR \fIfile\fR\fR
2398 .ad
2399 .RS 21n
2400 True, if \fIfile\fR exists and is a character special file.
2401 .RE
2402 
2403 .sp
2404 .ne 2
2405 .na
2406 \fB\fB-d\fR \fIfile\fR\fR
2407 .ad
2408 .RS 21n
2409 True, if \fIfile\fR exists and is a directory.
2410 .RE
2411 
2412 .sp
2413 .ne 2
2414 .na
2415 \fB\fB-e\fR \fIfile\fR\fR
2416 .ad
2417 .RS 21n
2418 True, if \fIfile\fR exists.
2419 .RE
2420 
2421 .sp
2422 .ne 2
2423 .na
2424 \fB\fB-f\fR \fIfile\fR\fR
2425 .ad
2426 .RS 21n
2427 True, if \fIfile\fR exists and is an ordinary file.
2428 .RE
2429 
2430 .sp
2431 .ne 2
2432 .na
2433 \fB\fB-g\fR \fIfile\fR\fR
2434 .ad
2435 .RS 21n
2436 True, if \fIfile\fR exists and it has its \fBsetgid\fR bit set.
2437 .RE
2438 
2439 .sp
2440 .ne 2
2441 .na
2442 \fB\fB-G\fR \fIfile\fR\fR
2443 .ad
2444 .RS 21n
2445 True, if \fIfile\fR exists and its group matches the effective group id of this
2446 process.
2447 .RE
2448 
2449 .sp
2450 .ne 2
2451 .na
2452 \fB\fB-h\fR \fIfile\fR\fR
2453 .ad
2454 .RS 21n
2455 True, if \fIfile\fR exists and is a symbolic link.
2456 .RE
2457 
2458 .sp
2459 .ne 2
2460 .na
2461 \fB\fB-k\fR \fIfile\fR\fR
2462 .ad
2463 .RS 21n
2464 True, if \fIfile\fR exists and it has its sticky bit set.
2465 .RE
2466 
2467 .sp
2468 .ne 2
2469 .na
2470 \fB\fB-L\fR \fIfile\fR\fR
2471 .ad
2472 .RS 21n
2473 True, if \fIfile\fR exists and is a symbolic link.
2474 .RE
2475 
2476 .sp
2477 .ne 2
2478 .na
2479 \fB\fB-n\fR \fIstring\fR\fR
2480 .ad
2481 .RS 21n
2482 True, if length of \fIstring\fR is \fBnon-zero\fR.
2483 .RE
2484 
2485 .sp
2486 .ne 2
2487 .na
2488 \fB\fB-N\fR \fIfile\fR\fR
2489 .ad
2490 .RS 21n
2491 True, if \fIfile\fR exists and the modification time is greater than the last
2492 access time.
2493 .RE
2494 
2495 .sp
2496 .ne 2
2497 .na
2498 \fB\fB-o\fR \fIoption\fR\fR
2499 .ad
2500 .RS 21n
2501 True, if option named \fIoption\fR is on.
2502 .RE
2503 
2504 .sp
2505 .ne 2
2506 .na
2507 \fB\fB-o\fR \fI?option\fR\fR
2508 .ad
2509 .RS 21n
2510 True, if option named \fIoption\fR is a valid option name.
2511 .RE
2512 
2513 .sp
2514 .ne 2
2515 .na
2516 \fB\fB-O\fR \fIfile\fR\fR
2517 .ad
2518 .RS 21n
2519 True, if \fIfile\fR exists and is owned by the effective user id of this
2520 process.
2521 .RE
2522 
2523 .sp
2524 .ne 2
2525 .na
2526 \fB\fB-p\fR \fIfile\fR\fR
2527 .ad
2528 .RS 21n
2529 True, if \fIfile\fR exists and is a \fBFIFO\fR special file or a pipe.
2530 .RE
2531 
2532 .sp
2533 .ne 2
2534 .na
2535 \fB\fB-r\fR \fIfile\fR\fR
2536 .ad
2537 .RS 21n
2538 True, if \fIfile\fR exists and is readable by current process.
2539 .RE
2540 
2541 .sp
2542 .ne 2
2543 .na
2544 \fB\fB-s\fR \fIfile\fR\fR
2545 .ad
2546 .RS 21n
2547 True, if \fIfile\fR exists and has size greater than zero.
2548 .RE
2549 
2550 .sp
2551 .ne 2
2552 .na
2553 \fB\fB-S\fR \fIfile\fR\fR
2554 .ad
2555 .RS 21n
2556 True, if \fIfile\fR exists and is a socket.
2557 .RE
2558 
2559 .sp
2560 .ne 2
2561 .na
2562 \fB\fB-t\fR \fIfildes\fR\fR
2563 .ad
2564 .RS 21n
2565 True, if file descriptor number \fIfildes\fR is open and associated with a
2566 terminal device.
2567 .RE
2568 
2569 .sp
2570 .ne 2
2571 .na
2572 \fB\fB-u\fR \fIfile\fR\fR
2573 .ad
2574 .RS 21n
2575 True, if \fIfile\fR exists and it has its \fBsetuid\fR bit set.
2576 .RE
2577 
2578 .sp
2579 .ne 2
2580 .na
2581 \fB\fB-w\fR \fIfile\fR\fR
2582 .ad
2583 .RS 21n
2584 True, if \fIfile\fR exists and is writable by current process.
2585 .RE
2586 
2587 .sp
2588 .ne 2
2589 .na
2590 \fB\fB-x\fR \fIfile\fR\fR
2591 .ad
2592 .RS 21n
2593 True, if \fIfile\fR exists and is executable by current process. If \fIfile\fR
2594 exists and is a directory, then true if the current process has permission to
2595 search in the directory.
2596 .RE
2597 
2598 .sp
2599 .ne 2
2600 .na
2601 \fB\fB-z\fR \fIstring\fR\fR
2602 .ad
2603 .RS 21n
2604 True, if length of \fIstring\fR is zero.
2605 .RE
2606 
2607 .sp
2608 .ne 2
2609 .na
2610 \fB\fIfile1\fR \fB-ef\fR \fIfile2\fR\fR
2611 .ad
2612 .RS 21n
2613 True, if \fIfile1\fR and \fIfile2\fR exist and refer to the same file.
2614 .RE
2615 
2616 .sp
2617 .ne 2
2618 .na
2619 \fB\fIfile1\fR \fB-nt\fR \fIfile2\fR\fR
2620 .ad
2621 .RS 21n
2622 True, if \fIfile1\fR exists and \fIfile2\fR does not, or \fIfile1\fR is newer
2623 than \fIfile2\fR.
2624 .RE
2625 
2626 .sp
2627 .ne 2
2628 .na
2629 \fB\fIfile1\fR \fB-ot\fR \fIfile2\fR\fR
2630 .ad
2631 .RS 21n
2632 True, if \fIfile2\fR exists and \fIfile1\fR does not, or \fIfile1\fR is older
2633 than \fIfile2\fR.
2634 .RE
2635 
2636 .sp
2637 .ne 2
2638 .na
2639 \fB\fIstring\fR\fR
2640 .ad
2641 .RS 21n
2642 True, if \fIstring\fR is not null.
2643 .RE
2644 
2645 .sp
2646 .ne 2
2647 .na
2648 \fB\fIstring\fR \fB==\fR \fIpattern\fR\fR
2649 .ad
2650 .RS 21n
2651 True, if \fIstring\fR matches \fIpattern\fR. Any part of \fIpattern\fR can be
2652 quoted to cause it to be matched as a string. With a successful match to
2653 \fIpattern\fR, the \fB\&.sh.match\fR array variable contains the match and
2654 sub-pattern matches.
2655 .RE
2656 
2657 .sp
2658 .ne 2
2659 .na
2660 \fB\fIstring\fR \fB=\fR \fIpattern\fR\fR
2661 .ad
2662 .RS 21n
2663 Same as \fB==\fR, but is obsolete.
2664 .RE
2665 
2666 .sp
2667 .ne 2
2668 .na
2669 \fB\fIstring\fR \fB!=\fR \fIpattern\fR\fR
2670 .ad
2671 .RS 21n
2672 True, if \fIstring\fR does not match \fIpattern\fR. When the \fIstring\fR
2673 matches the \fIpattern\fR the \fB\&.sh.match\fR array variable contains the
2674 match and sub-pattern matches.
2675 .RE
2676 
2677 .sp
2678 .ne 2
2679 .na
2680 \fB\fIstring\fR \fB=~\fR \fIere\fR\fR
2681 .ad
2682 .RS 21n
2683 True if \fIstring\fR matches the pattern \fB~(E)\fR\fIere\fR where \fIere\fR is
2684 an extended regular expression.
2685 .RE
2686 
2687 .sp
2688 .ne 2
2689 .na
2690 \fB\fIstring1\fR \fB<\fR \fIstring2\fR\fR
2691 .ad
2692 .RS 21n
2693 True, if \fIstring1\fR comes before \fIstring2\fR based on \fBASCII\fR value of
2694 their characters.
2695 .RE
2696 
2697 .sp
2698 .ne 2
2699 .na
2700 \fB\fIstring1\fR \fB>\fR \fIstring2\fR\fR
2701 .ad
2702 .RS 21n
2703 True, if \fIstring1\fR comes after \fIstring2\fR based on \fBASCII\fR value of
2704 their characters.
2705 .RE
2706 
2707 .sp
2708 .LP
2709 In each of the following expressions, if \fIfile\fR is of the form
2710 \fB/dev/fd/\fR\fIn\fR, where \fIn\fR is an integer, the test is applied to the
2711 open file whose descriptor number is \fIn\fR. The following obsolete arithmetic
2712 comparisons are supported:
2713 .sp
2714 .ne 2
2715 .na
2716 \fB\fIexp1\fR \fB-eq\fR \fIexp2\fR\fR
2717 .ad
2718 .RS 17n
2719 True, if \fIexp1\fR is equal to \fIexp2\fR.
2720 .RE
2721 
2722 .sp
2723 .ne 2
2724 .na
2725 \fB\fIexp1\fR \fB-ge\fR \fIexp2\fR\fR
2726 .ad
2727 .RS 17n
2728 True, if \fIexp1\fR is greater than or equal to \fIexp2\fR.
2729 .RE
2730 
2731 .sp
2732 .ne 2
2733 .na
2734 \fB\fIexp1\fR \fB-gt\fR \fIexp2\fR\fR
2735 .ad
2736 .RS 17n
2737 True, if \fIexp1\fR is greater than \fIexp2\fR.
2738 .RE
2739 
2740 .sp
2741 .ne 2
2742 .na
2743 \fB\fIexp1\fR \fB-le\fR \fIexp2\fR\fR
2744 .ad
2745 .RS 17n
2746 True, if \fIexp1\fR is less than or equal to \fIexp2\fR.
2747 .RE
2748 
2749 .sp
2750 .ne 2
2751 .na
2752 \fB\fIexp1\fR \fB-lt\fR \fIexp2\fR\fR
2753 .ad
2754 .RS 17n
2755 True, if \fIexp1\fR is less than \fIexp2\fR.
2756 .RE
2757 
2758 .sp
2759 .ne 2
2760 .na
2761 \fB\fIexp1\fR \fB-ne\fR \fIexp2\fR\fR
2762 .ad
2763 .RS 17n
2764 True, if \fIexp1\fR is not equal to \fIexp2\fR.
2765 .RE
2766 
2767 .sp
2768 .LP
2769 A compound expression can be constructed from these primitives by using any of
2770 the following, listed in decreasing order of precedence:
2771 .sp
2772 .ne 2
2773 .na
2774 \fB\fB(\fR\fIexpression\fR\fB)\fR\fR
2775 .ad
2776 .RS 30n
2777 True, if \fIexpression\fR is true. Used to group expressions.
2778 .RE
2779 
2780 .sp
2781 .ne 2
2782 .na
2783 \fB\fB!\fR \fIexpression\fR\fR
2784 .ad
2785 .RS 30n
2786 True, if \fIexpression\fR is false.
2787 .RE
2788 
2789 .sp
2790 .ne 2
2791 .na
2792 \fB\fIexpression1\fR \fB&&\fR \fIexpression2\fR\fR
2793 .ad
2794 .RS 30n
2795 True, if \fIexpression1\fR and \fIexpression2\fR are both true.
2796 .RE
2797 
2798 .sp
2799 .ne 2
2800 .na
2801 \fB\fIexpression1\fR \fB||\fR \fIexpression2\fR\fR
2802 .ad
2803 .RS 30n
2804 True, if either \fIexpression1\fR or \fIexpression2\fR is true.
2805 .RE
2806 
2807 .SS "Input and Output"
2808 .sp
2809 .LP
2810 Before a command is executed, its input and output can be redirected using a
2811 special notation interpreted by the shell. The following can appear anywhere in
2812 a simple command or can precede or follow a command and are \fBnot\fR passed on
2813 to the invoked command. Command substitution, parameter expansion, and
2814 arithmetic substitution occur before \fIword\fR or \fIdigit\fR is used except
2815 as noted in this section. File name generation occurs only if the shell is
2816 interactive and the pattern matches a single file. Field splitting is not
2817 performed.
2818 .sp
2819 .LP
2820 In each of the following redirections, if \fIfile\fR is of the form
2821 \fB/dev/sctp/\fR\fIhost\fR\fB/\fR\fIport\fR,
2822 \fB/dev/tcp/\fR\fIhost\fR\fB/\fR\fIport\fR, or
2823 \fB/dev/udp/\fR\fIhost\fR\fB/\fR\fIport\fR, where \fIhost\fR is a hostname or
2824 host address, and \fIport\fR is a service specified by name or an integer port
2825 number, then the redirection attempts to make a \fBtcp\fR, \fBsctp\fR or
2826 \fBudp\fR connection to the corresponding socket.
2827 .sp
2828 .LP
2829 No intervening space is allowed between the characters of redirection
2830 operators.
2831 .sp
2832 .ne 2
2833 .na
2834 \fB\fB<\fR\fIword\fR\fR
2835 .ad
2836 .RS 14n
2837 Use file \fIword\fR as standard input (file descriptor 0).
2838 .RE
2839 
2840 .sp
2841 .ne 2
2842 .na
2843 \fB\fB>\fR\fIword\fR\fR
2844 .ad
2845 .RS 14n
2846 Use file \fIword\fR as standard output (file descriptor 1). If the file does
2847 not exist then it is created. If the file exists, and the \fBnoclobber\fR
2848 option is on, this causes an error. Otherwise, it is truncated to zero length.
2849 .RE
2850 
2851 .sp
2852 .ne 2
2853 .na
2854 \fB\fB>|\fR\fIword\fR\fR
2855 .ad
2856 .RS 14n
2857 Same as \fB>\fR, except that it overrides the \fBnoclobber\fR option.
2858 .RE
2859 
2860 .sp
2861 .ne 2
2862 .na
2863 \fB\fB>>\fR\fIword\fR\fR
2864 .ad
2865 .RS 14n
2866 Use file \fIword\fR as standard output. If the file exists, then output is
2867 appended to it (by first seeking to the end-of-file). Otherwise, the file is
2868 created.
2869 .RE
2870 
2871 .sp
2872 .ne 2
2873 .na
2874 \fB\fB<>\fR\fIword\fR\fR
2875 .ad
2876 .RS 14n
2877 Open file \fIword\fR for reading and writing as standard input.
2878 .RE
2879 
2880 .sp
2881 .ne 2
2882 .na
2883 \fB\fB<<\fR\fB[-]\fR\fIword\fR\fR
2884 .ad
2885 .RS 14n
2886 The shell input is read up to a line that is the same as \fIword\fR after any
2887 quoting has been removed, or to an end-of-file. No parameter substitution,
2888 command substitution, arithmetic substitution or file name generation is
2889 performed on \fIword\fR. The resulting document, called a \fBhere-document\fR,
2890 becomes the standard input. If any character of \fIword\fR is quoted, then no
2891 interpretation is placed upon the characters of the document. Otherwise,
2892 parameter expansion, command substitution, and arithmetic substitution occur,
2893 \fB\e\fRNEWLINE is ignored, and \fB\e\fR must be used to quote the characters
2894 \fB\e\fR, \fB$\fR, \fB`\fR\&. If \fB-\fR is appended to \fB<<\fR, then all
2895 leading tabs are stripped from \fIword\fR and from the document. If \fB#\fR is
2896 appended to \fB<<\fR, then leading SPACEs and TABs are stripped off the first
2897 line of the document and up to an equivalent indentation is stripped from the
2898 remaining lines and from \fIword\fR. A tab stop is assumed to occur at every 8
2899 columns for the purposes of determining the indentation.
2900 .RE
2901 
2902 .sp
2903 .ne 2
2904 .na
2905 \fB\fB<<<\fR\fIword\fR\fR
2906 .ad
2907 .RS 14n
2908 A short form of here document in which \fIword\fR becomes the contents of the
2909 here-document after any parameter expansion, command substitution, and
2910 arithmetic substitution occur.
2911 .RE
2912 
2913 .sp
2914 .ne 2
2915 .na
2916 \fB\fB<&\fR\fIdigit\fR\fR
2917 .ad
2918 .RS 14n
2919 The standard input is duplicated from file descriptor \fIdigit\fR, and
2920 similarly for the standard output using \fB>&\fR\fIdigit\fR. See \fBdup\fR(2).
2921 .RE
2922 
2923 .sp
2924 .ne 2
2925 .na
2926 \fB\fB<&\fR\fIdigit\fR\fB-\fR\fR
2927 .ad
2928 .RS 14n
2929 The file descriptor specified by \fIdigit\fR is moved to standard input.
2930 Similarly for the standard output using \fB>&\fR\fIdigit\fR\fB-\fR.
2931 .RE
2932 
2933 .sp
2934 .ne 2
2935 .na
2936 \fB\fB<&-\fR\fR
2937 .ad
2938 .RS 14n
2939 The standard input is closed. Similarly for the standard output using
2940 \fB>&-\fR.
2941 .RE
2942 
2943 .sp
2944 .ne 2
2945 .na
2946 \fB\fB<&p\fR\fR
2947 .ad
2948 .RS 14n
2949 The input from the co-process is moved to standard input.
2950 .RE
2951 
2952 .sp
2953 .ne 2
2954 .na
2955 \fB\fB>&p\fR\fR
2956 .ad
2957 .RS 14n
2958 The output to the co-process is moved to standard output.
2959 .RE
2960 
2961 .sp
2962 .ne 2
2963 .na
2964 \fB\fB<#((\fR\fIexpr\fR\fB))\fR\fR
2965 .ad
2966 .RS 14n
2967 Evaluate arithmetic expression \fIexpr\fR and position file descriptor 0 to the
2968 resulting value bytes from the start of the file. The variables \fBCUR\fR and
2969 \fBEOF\fR evaluate to the current offset and end-of-file offset respectively
2970 when evaluating \fIexpr\fR.
2971 .RE
2972 
2973 .sp
2974 .ne 2
2975 .na
2976 \fB\fB>#((\fR\fIexpr\fR\fB))\fR\fR
2977 .ad
2978 .RS 14n
2979 The same as \fB<#\fR except applies to file descriptor 1.
2980 .RE
2981 
2982 .sp
2983 .ne 2
2984 .na
2985 \fB\fB<#\fR\fIpattern\fR\fR
2986 .ad
2987 .RS 14n
2988 Seek forward to the beginning of the next line containing pattern.
2989 .RE
2990 
2991 .sp
2992 .ne 2
2993 .na
2994 \fB\fB<##\fR\fIpattern\fR\fR
2995 .ad
2996 .RS 14n
2997 The same as \fB<#\fR, except that the portion of the file that is skipped is
2998 copied to standard output.
2999 .RE
3000 
3001 .sp
3002 .LP
3003 If one of the redirection operators is preceded by a digit, with no intervening
3004 space, then the file descriptor number referred to is that specified by the
3005 digit (instead of the default 0 or 1). If one of the redirection operators
3006 other than \fB>&-\fR and the \fB>#\fR and \fB<#\fR forms, is preceded by
3007 \fB{\fR\fIvarname\fR\fB}\fR with no intervening space, then a file descriptor
3008 number \fB> 10\fR is selected by the shell and stored in the variable
3009 \fIvarname\fR. If \fB>&-\fR or the any of the \fB>#\fR and \fB<#\fR forms is
3010 preceded by \fB{\fR\fIvarname\fR\fB}\fR the value of \fIvarname\fR defines the
3011 file descriptor to close or position. For example:
3012 .sp
3013 .in +2
3014 .nf
3015 \&... 2>&1
3016 .fi
3017 .in -2
3018 .sp
3019 
3020 .sp
3021 .LP
3022 means file descriptor 2 is to be opened for writing as a duplicate of file
3023 descriptor 1 and
3024 .sp
3025 .in +2
3026 .nf
3027 exec [\fIn\fR]<\fIfile\fR
3028 .fi
3029 .in -2
3030 .sp
3031 
3032 .sp
3033 .LP
3034 means open \fIfile\fR for reading and store the file descriptor number in
3035 variable \fIn\fR. The order in which redirections are specified is significant.
3036 The shell evaluates each redirection in terms of the (\fIfile_descriptor\fR,
3037 \fIfile\fR) association at the time of evaluation. For example:
3038 .sp
3039 .in +2
3040 .nf
3041 \&... 1>\fIfname\fR 2>&1
3042 .fi
3043 .in -2
3044 .sp
3045 
3046 .sp
3047 .LP
3048 first associates file descriptor 1 with file \fIfname\fR. It then associates
3049 file descriptor 2 with the file associated with file descriptor 1, that is,
3050 \fIfname\fR. If the order of redirections were reversed, file descriptor 2
3051 would be associated with the terminal (assuming file descriptor 1 had been) and
3052 then file descriptor 1 would be associated with file \fIfname\fR. If a command
3053 is followed by \fB&\fR and job control is not active, the default standard
3054 input for the command is the empty file \fB/dev/null\fR. Otherwise, the
3055 environment for the execution of a command contains the file descriptors of the
3056 invoking shell as modified by input and output specifications.
3057 .SS "Environment"
3058 .sp
3059 .LP
3060 The \fIenvironment\fR is a list of name-value pairs that is passed to an
3061 executed program in the same way as a normal argument list. See
3062 \fBenviron\fR(5).
3063 .sp
3064 .LP
3065 The names must be \fIidentifiers\fR and the values are character strings. The
3066 shell interacts with the environment in several ways. On invocation, the shell
3067 scans the environment and creates a variable for each name found, giving it the
3068 corresponding value and attributes and marking it \fBexport\fR. Executed
3069 commands inherit the environment. If the user modifies the values of these
3070 variables or creates new ones, using the \fBexport\fR or \fBtypeset\fR \fB-x\fR
3071 commands, they become part of the environment. The environment seen by any
3072 executed command is thus composed of any name-value pairs originally inherited
3073 by the shell, whose values can be modified by the current shell, plus any
3074 additions which must be noted in \fBexport\fR or \fBtypeset\fR \fB-x\fR
3075 commands. The environment for any simple-command or function can be augmented
3076 by prefixing it with one or more variable assignments. A variable assignment
3077 argument is a word of the form \fIidentifier\fR\fB=\fR\fIvalue\fR. Thus:
3078 .sp
3079 .in +2
3080 .nf
3081 TERM=450 cmd args
3082 .fi
3083 .in -2
3084 .sp
3085 
3086 .sp
3087 .LP
3088 and
3089 .sp
3090 .in +2
3091 .nf
3092 (export TERM; TERM=450; cmd args)
3093 .fi
3094 .in -2
3095 .sp
3096 
3097 .sp
3098 .LP
3099 are equivalent (as far as the execution of \fIcmd\fR is concerned except for
3100 special built-in commands listed in the \fBBuilt-Ins\fR section, those that are
3101 preceded with a dagger. If the obsolete \fB-k\fR option is set, all variable
3102 assignment arguments are placed in the environment, even if they occur after
3103 the command name.
3104 .sp
3105 .LP
3106 The following example first prints \fBa=b c\fR and then \fBc\fR:
3107 .sp
3108 .in +2
3109 .nf
3110 echo a=b c
3111 set -k
3112 echo a=b c
3113 .fi
3114 .in -2
3115 .sp
3116 
3117 .sp
3118 .LP
3119 This feature is intended for use with scripts written for early versions of the
3120 shell and its use in new scripts is strongly discouraged.
3121 .SS "Functions"
3122 .sp
3123 .LP
3124 For historical reasons, there are two ways to define functions, the
3125 \fBname()\fR syntax and the \fBfunction\fR \fBname\fR syntax. These are
3126 described in the \fBCommands\fR section of this manual page.
3127 .sp
3128 .LP
3129 Shell functions are read in and stored internally. Alias names are resolved
3130 when the function is read. Functions are executed like commands with the
3131 arguments passed as positional parameters. See the \fBExecution\fR section of
3132 this manual page for details.
3133 .sp
3134 .LP
3135 Functions defined by the \fBfunction\fR \fBname\fR syntax and called by name
3136 execute in the same process as the caller and share all files and present
3137 working directory with the caller. Traps caught by the caller are reset to
3138 their default action inside the function. A trap condition that is not caught
3139 or ignored by the function causes the function to terminate and the condition
3140 to be passed on to the caller. A trap on \fBEXIT\fR set inside a function is
3141 executed in the environment of the caller after the function completes.
3142 Ordinarily, variables are shared between the calling program and the function.
3143 However, the \fBtypeset\fR special built-in command used within a function
3144 defines local variables whose scope includes the current function. They can be
3145 passed to functions that they call in the variable assignment list that
3146 precedes the call or as arguments passed as name references. Errors within
3147 functions return control to the caller.
3148 .sp
3149 .LP
3150 Functions defined with the \fBname()\fR syntax and functions defined with the
3151 \fBfunction\fR \fBname\fR syntax that are invoked with the \fB\&.\fR special
3152 built-in are executed in the caller's environment and share all variables and
3153 traps with the caller. Errors within these function executions cause the script
3154 that contains them to abort.
3155 .sp
3156 .LP
3157 The special built-in command \fBreturn\fR is used to return from function
3158 calls.
3159 .sp
3160 .LP
3161 Function names can be listed with the \fB-f\fR or \fB+f\fR option of the
3162 \fBtypeset\fR special built-in command. The text of functions, when available,
3163 is also listed with \fB-f\fR. Functions can be undefined with the \fB-f\fR
3164 option of the \fBunset\fR special built-in command.
3165 .sp
3166 .LP
3167 Ordinarily, functions are unset when the shell executes a shell script.
3168 Functions that need to be defined across separate invocations of the shell
3169 should be placed in a directory and the \fBFPATH\fR variable should contain the
3170 name of this directory. They can also be specified in the \fBENV\fR file.
3171 .SS "Discipline Functions"
3172 .sp
3173 .LP
3174 Each variable can have zero or more discipline functions associated with it.
3175 The shell initially understands the discipline names \fBget\fR, \fBset\fR,
3176 \fBappend\fR, and \fBunset\fR but on most systems others can be added at run
3177 time via the C programming interface extension provided by the \fBbuiltin\fR
3178 built-in utility. If the \fBget\fR discipline is defined for a variable, it is
3179 invoked whenever the specified variable is referenced. If the variable
3180 \fB\&.sh.value\fR is assigned a value inside the discipline function, the
3181 referenced variable is evaluated to this value instead. If the \fBset\fR
3182 discipline is defined for a variable, it is invoked whenever the specified
3183 variable is assigned a value. If the \fBappend\fR discipline is defined for a
3184 variable, it is invoked whenever a value is appended to the specified variable.
3185 The variable \fB\&.sh.value\fR is specified the value of the variable before
3186 invoking the discipline, and the variable is assigned the value of
3187 \fB\&.sh.value\fR after the discipline completes. If .\fBsh.value\fR is
3188 \fBunset\fR inside the discipline, then that value is unchanged. If the
3189 \fBunset\fR discipline is defined for a variable, it is invoked whenever the
3190 specified variable is unset. The variable is not unset unless it is unset
3191 explicitly from within this discipline function.
3192 .sp
3193 .LP
3194 The variable \fB\&.sh.name\fR contains the name of the variable for which the
3195 discipline function is called, \fB\&.sh.subscript\fR is the subscript of the
3196 variable, and \fB\&.sh.value\fR contains the value being assigned inside the
3197 \fBset\fR discipline function. For the \fBset\fR discipline, changing
3198 \fB\&.sh.value\fR changes the value that gets assigned.
3199 .SS "Jobs"
3200 .sp
3201 .LP
3202 If the monitor option of the \fBset\fR command is turned on, an interactive
3203 shell associates a job with each pipeline. It keeps a table of current jobs,
3204 printed by the \fBjobs\fR command, and assigns them small integer numbers. When
3205 a job is started asynchronously with \fB&\fR, the shell prints a line which
3206 looks like:
3207 .sp
3208 .in +2
3209 .nf
3210 [1] 1234
3211 .fi
3212 .in -2
3213 .sp
3214 
3215 .sp
3216 .LP
3217 indicating that the job which was started asynchronously was job number 1 and
3218 had one (top-level) process, whose process id was \fB1234\fR.
3219 .sp
3220 .LP
3221 If you are running a job and wish to stop it, CTRL-z sends a \fBSTOP\fR signal
3222 to the current job. The shell normally displays a message that the job has been
3223 stopped, and displays another prompt. You can then manipulate the state of this
3224 job, putting it in the background with the \fBbg\fR command, or run some other
3225 commands and then eventually bring the job back into the foreground with the
3226 foreground command \fBfg\fR. A CTRL-z takes effect immediately and is like an
3227 interrupt in that pending output and unread input are discarded when it is
3228 typed.
3229 .sp
3230 .LP
3231 A job being run in the background stops if it tries to read from the terminal.
3232 Background jobs are normally allowed to produce output, but this can be
3233 disabled by giving the command \fBsttytostop\fR. If you set this \fBtty\fR
3234 option, then background jobs stop when they try to produce output like they do
3235 when they try to read input.
3236 .sp
3237 .LP
3238 There are several ways to refer to jobs in the shell. A job can be referred to
3239 by the process id of any process of the job or by one of the following:
3240 .sp
3241 .ne 2
3242 .na
3243 \fB\fB%\fR\fInumber\fR\fR
3244 .ad
3245 .RS 12n
3246 The job with the specified number.
3247 .RE
3248 
3249 .sp
3250 .ne 2
3251 .na
3252 \fB\fB%\fR\fIstring\fR\fR
3253 .ad
3254 .RS 12n
3255 Any job whose command line begins with \fIstring\fR.
3256 .RE
3257 
3258 .sp
3259 .ne 2
3260 .na
3261 \fB\fB%?\fR\fIstring\fR\fR
3262 .ad
3263 .RS 12n
3264 Any job whose command line contains \fIstring\fR.
3265 .RE
3266 
3267 .sp
3268 .ne 2
3269 .na
3270 \fB\fB%%\fR\fR
3271 .ad
3272 .RS 12n
3273 Current job.
3274 .RE
3275 
3276 .sp
3277 .ne 2
3278 .na
3279 \fB\fB%+\fR\fR
3280 .ad
3281 .RS 12n
3282 Equivalent to \fB%%\fR.
3283 .RE
3284 
3285 .sp
3286 .ne 2
3287 .na
3288 \fB\fB%-\fR\fR
3289 .ad
3290 .RS 12n
3291 Previous job.
3292 .RE
3293 
3294 .sp
3295 .LP
3296 The shell learns immediately whenever a process changes state. It normally
3297 informs you whenever a job becomes blocked so that no further progress is
3298 possible, but only just before it prints a prompt. This is done so that it does
3299 not otherwise disturb your work. The notify option of the \fBset\fR command
3300 causes the shell to print these job change messages as soon as they occur.
3301 .sp
3302 .LP
3303 When the \fBmonitor\fR option is on, each background job that completes
3304 triggers any trap set for \fBCHLD\fR.
3305 .sp
3306 .LP
3307 When you try to leave the shell while jobs are running or stopped, you are
3308 warned that \fBYou have stopped(running) jobs.\fR You can use the \fBjobs\fR
3309 command to see what they are. If you immediately try to exit again, the shell
3310 does not warn you a second time, and the stopped jobs are terminated. When a
3311 login shell receives a \fBHUP\fR signal, it sends a \fBHUP\fR signal to each
3312 job that has not been disowned with the \fBdisown\fR built-in command.
3313 .SS "Signals"
3314 .sp
3315 .LP
3316 The \fBINT\fR and \fBQUIT\fR signals for an invoked command are ignored if the
3317 command is followed by \fB&\fR and the \fBmonitor\fR option is not active.
3318 Otherwise, signals have the values inherited by the shell from its parent. See
3319 the \fBtrap\fR built-in command.
3320 .SS "Execution"
3321 .sp
3322 .LP
3323 Each time a command is read, the substitutions are carried out. If the command
3324 name matches one of the ones in the \fBSpecial Built-in Commands\fR section of
3325 this manual page, it is executed within the current shell process. Next, the
3326 command name is checked to see if it matches a user defined function. If it
3327 does, the positional parameters are saved and then reset to the arguments of
3328 the function call. A function is also executed in the current shell process.
3329 When the function completes or issues a return, the positional parameter list
3330 is restored. For functions defined with the \fBfunction\fR \fBname\fR syntax,
3331 any trap set on \fBEXIT\fR within the function is executed. The exit value of a
3332 function is the value of the last command executed. If a command name is not a
3333 special built-in command or a user defined function, but it is one of the
3334 built-in commands, it is executed in the current shell process.
3335 .sp
3336 .LP
3337 The shell variable \fBPATH\fR defines the search path for the directory
3338 containing the command. Alternative directory names are separated by a colon
3339 (\fB:\fR). The default path is \fB/bin:/usr/bin:\fR, specifying \fB/bin\fR,
3340 \fB/usr/bin\fR, and the current directory in that order. The current directory
3341 can be specified by two or more adjacent colons, or by a colon at the beginning
3342 or end of the path list. If the command name contains a slash (\fB/\fR), the
3343 search path is not used. Otherwise, each directory in the path is searched for
3344 an executable file of the specified name that is not a directory. If found, and
3345 if the shell determines that there is a built-in version of a command
3346 corresponding to a specified pathname, this built-in is invoked in the current
3347 process. If found, and this directory is also contained in the value of the
3348 \fBFPATH\fR variable, then this file is loaded into the current shell
3349 environment as if it were the argument to the . command except that only preset
3350 aliases are expanded, and a function of the specified name is executed as
3351 described in this manual page. If not found, and the file \fB\&.paths\fR is
3352 found, and this file contains a line of the form \fBFPATH=\fR\fIpath\fR where
3353 \fIpath\fR is an existing directory, and this directory contains a file of the
3354 specified name, then this file is loaded into the current shell environment as
3355 if it were the argument to the \fB\&. special\fR built-in command and a
3356 function of the specified name is executed. Otherwise, if found, a process is
3357 created and an attempt is made to execute the command using \fBexec\fR(2).
3358 .sp
3359 .LP
3360 When an executable is found, the directory where it is found in is searched for
3361 a file named \fB\&.paths\fR. If this file is found and it contains a line of
3362 the form \fBBUILTIN_LIB=\fR\fIvalue\fR, the library named by \fIvalue\fR is
3363 searched for as if it were an option argument to \fBbuiltin -f\fR, and if it
3364 contains a built-in of the specified name this is executed instead of a command
3365 by this name. Otherwise, if this file is found and it contains a line of the
3366 form \fIname\fR\fB=\fR\fIvalue\fR in the first or second line, then the
3367 environment variable \fIname\fR is modified by prepending the directory
3368 specified by \fIvalue\fR to the directory list. If \fIvalue\fR is not an
3369 absolute directory, then it specifies a directory relative to the directory
3370 that the executable was found. If the environment variable \fIname\fR does not
3371 already exist it is added to the environment list for the specified command.
3372 .sp
3373 .LP
3374 If the file has execute permission but is not an \fBa.out\fR file, it is
3375 assumed to be a file containing shell commands. A separate shell is spawned to
3376 read it. All non-exported variables are removed in this case. If the shell
3377 command file doesn't have read permission, and/or if the \fBsetuid\fR and
3378 \fBsetgid\fR bits are set on the file, then the shell executes an agent whose
3379 job it is to set up the permissions and execute the shell with the shell
3380 command file passed down as an open file. A parenthesized command is executed
3381 in a sub-shell without removing non-exported variables.
3382 .SS "Command Re-entry"
3383 .sp
3384 .LP
3385 The text of the last \fBHISTSIZE\fR (default 512) commands entered from a
3386 terminal device is saved in a history file. The file \fB$HOME/.sh_history\fR is
3387 used if the \fBHISTFILE\fR variable is not set or if the file it names is not
3388 writable. A shell can access the commands of all interactive shells which use
3389 the same named \fBHISTFILE\fR. The built-in command \fBhist\fR is used to list
3390 or edit a portion of this file. The portion of the file to be edited or listed
3391 can be selected by number or by giving the first character or characters of the
3392 command. A single command or range of commands can be specified. If you do not
3393 specify an editor program as an argument to \fBhist\fR then the value of the
3394 variable \fBHISTEDIT\fR is used. If \fBHISTEDIT\fR is unset, the obsolete
3395 variable \fBFCEDIT\fR is used. If \fBFCEDIT\fR is not defined, then
3396 \fB/bin/ed\fR is used. The edited commands are printed and executed again upon
3397 leaving the editor unless you quit without writing. The \fB-s\fR option (and in
3398 obsolete versions, the editor name \fB-\fR) is used to skip the editing phase
3399 and to re-execute the command. In this case a substitution parameter of the
3400 form \fIold\fR\fB=\fR\fInew\fRcan be used to modify the command before
3401 execution. For example, with the preset alias \fBr\fR, which is aliased to
3402 \fB\&'hist -s'\fR, typing \fB`r bad=good c'\fR re-executes the most recent
3403 command which starts with the letter \fBc\fR, replacing the first occurrence of
3404 the string bad with the string good.
3405 .SS "Inline Editing Options"
3406 .sp
3407 .LP
3408 Normally, each command line entered from a terminal device is simply typed
3409 followed by a NEWLINE (RETURN or LINE FEED). If either the \fBemacs\fR,
3410 \fBgmacs\fR, or \fBvi\fR option is active, the user can edit the command line.
3411 To be in either of these edit modes set the corresponding option. An editing
3412 option is automatically selected each time the \fBVISUAL\fR or \fBEDITOR\fR
3413 variable is assigned a value ending in either of these option names.
3414 .sp
3415 .LP
3416 The editing features require that the user's terminal accept RETURN as carriage
3417 return without line feed and that a SPACE must overwrite the current character
3418 on the screen.
3419 .sp
3420 .LP
3421 Unless the \fBmultiline\fR option is on, the editing modes implement a concept
3422 where the user is looking through a window at the current line. The window
3423 width is the value of \fBCOLUMNS\fR if it is defined, otherwise \fB80\fR. If
3424 the window width is too small to display the prompt and leave at least 8
3425 columns to enter input, the prompt is truncated from the left. If the line is
3426 longer than the window width minus two, a mark is displayed at the end of the
3427 window to notify the user. As the cursor moves and reaches the window
3428 boundaries the window is centered about the cursor. The mark is a \fB>\fR
3429 (\fB<, *\fR) if the line extends on the right , left, or both sides of the
3430 window.
3431 .sp
3432 .LP
3433 The search commands in each edit mode provide access to the history file. Only
3434 strings are matched, not patterns, although a leading \fB^\fR in the string
3435 restricts the match to begin at the first character in the line.
3436 .sp
3437 .LP
3438 Each of the edit modes has an operation to list the files or commands that
3439 match a partially entered word. When applied to the first word on the line, or
3440 the first word after a \fB;\fR, \fB|\fR, \fB&\fR, or \fB(\fR, and the word does
3441 not begin with \fB~\fR or contain a \fB/\fR, the list of aliases, functions,
3442 and executable commands defined by the \fBPATH\fR variable that could match the
3443 partial word is displayed. Otherwise, the list of files that match the
3444 specified word is displayed. If the partially entered word does not contain any
3445 file expansion characters, a \fB*\fR is appended before generating these lists.
3446 After displaying the generated list, the input line is redrawn. These
3447 operations are called command name listing and file name listing, respectively.
3448 There are additional operations, referred to as command name completion and
3449 file name completion, which compute the list of matching commands or files, but
3450 instead of printing the list, replace the current word with a complete or
3451 partial match. For file name completion, if the match is unique, a \fB/\fR is
3452 appended if the file is a directory and a space is appended if the file is not
3453 a directory. Otherwise, the longest common prefix for all the matching files
3454 replaces the word. For command name completion, only the portion of the file
3455 names after the last \fB/\fR are used to find the longest command prefix. If
3456 only a single name matches this prefix, then the word is replaced with the
3457 command name followed by a space. When using a \fBTAB\fR for completion that
3458 does not yield a unique match, a subsequent TAB provides a numbered list of
3459 matching alternatives. A specific selection can be made by entering the
3460 selection number followed by a TAB.
3461 .SS "Key Bindings"
3462 .sp
3463 .LP
3464 The \fBKEYBD\fR trap can be used to intercept keys as they are typed and change
3465 the characters that are actually seen by the shell. This trap is executed after
3466 each character (or sequence of characters when the first character is ESC) is
3467 entered while reading from a terminal.
3468 .sp
3469 .LP
3470 The variable \fB\&.sh.edchar\fR contains the character or character sequence
3471 which generated the trap. Changing the value of \fB\&.sh.edchar\fR in the trap
3472 action causes the shell to behave as if the new value were entered from the
3473 keyboard rather than the original value. The variable \fB\&.sh.edcol\fR is set
3474 to the input column number of the cursor at the time of the input. The variable
3475 \fB\&.sh.edmode\fR is set to \fBESC\fR when in \fBvi\fR insert mode and is null
3476 otherwise. By prepending \fB${.sh.editmode}\fR to a value assigned to
3477 \fB\&.sh.edchar\fR it causes the shell to change to control mode if it is not
3478 already in this mode.
3479 .sp
3480 .LP
3481 This trap is not invoked for characters entered as arguments to editing
3482 directives, or while reading input for a character search.
3483 .SS "\fBemacs\fR Editing Mode"
3484 .sp
3485 .LP
3486 This mode is entered by enabling either the \fBemacs\fR or \fBgmacs\fR option.
3487 The only difference between these two modes is the way they handle \fB^T\fR. To
3488 edit, the user moves the cursor to the point needing correction and then
3489 inserts or deletes characters or words as needed. All the editing commands are
3490 control characters or escape sequences. The notation for control characters is
3491 caret (\fB^\fR) followed by the character.
3492 .sp
3493 .LP
3494 For example, \fB^F\fR is the notation for CTRL/F. This is entered by depressing
3495 \fBf\fR while holding down the CTRL (control) key. The SHIFT key is not
3496 depressed. (The notation \fB^?\fR indicates the DEL (delete) key.)
3497 .sp
3498 .LP
3499 The notation for escape sequences is \fBM-\fR followed by a character. For
3500 example, \fBM-f\fR (pronounced \fBMeta f\fR) is entered by depressing ESC
3501 (\fBASCII 033\fR) followed by \fBf\fR. \fBM-F\fR is the notation for ESC
3502 followed by \fBF\fR.
3503 .sp
3504 .LP
3505 All edit commands operate from any place on the line, not just at the
3506 beginning. The RETURN or the LINE FEED key is not entered after edit commands
3507 except when noted.
3508 .sp
3509 .ne 2
3510 .na
3511 \fB\fB^F\fR\fR
3512 .ad
3513 .RS 13n
3514 Move the cursor forward (right) one character.
3515 .RE
3516 
3517 .sp
3518 .ne 2
3519 .na
3520 \fB\fBM-[C\fR\fR
3521 .ad
3522 .RS 13n
3523 Move the cursor forward (right) one character.
3524 .RE
3525 
3526 .sp
3527 .ne 2
3528 .na
3529 \fB\fBM-f\fR\fR
3530 .ad
3531 .RS 13n
3532 Move the cursor forward one word. The \fBemacs\fR editor's idea of a word is a
3533 string of characters consisting of only letters, digits and underscores.
3534 .RE
3535 
3536 .sp
3537 .ne 2
3538 .na
3539 \fB\fB^B\fR\fR
3540 .ad
3541 .RS 13n
3542 Move the cursor backward (left) one character.
3543 .RE
3544 
3545 .sp
3546 .ne 2
3547 .na
3548 \fB\fBM-[D\fR\fR
3549 .ad
3550 .RS 13n
3551 Move the cursor backward (left) one character.
3552 .RE
3553 
3554 .sp
3555 .ne 2
3556 .na
3557 \fB\fBM-b\fR\fR
3558 .ad
3559 .RS 13n
3560 Move the cursor backward one word.
3561 .RE
3562 
3563 .sp
3564 .ne 2
3565 .na
3566 \fB\fB^A\fR\fR
3567 .ad
3568 .RS 13n
3569 Move the cursor to the beginning of the line.
3570 .RE
3571 
3572 .sp
3573 .ne 2
3574 .na
3575 \fB\fBM-[H\fR\fR
3576 .ad
3577 .RS 13n
3578 Move the cursor to the beginning of the line.
3579 .RE
3580 
3581 .sp
3582 .ne 2
3583 .na
3584 \fB\fB^E\fR\fR
3585 .ad
3586 .RS 13n
3587 Move the cursor to the end of the line.
3588 .RE
3589 
3590 .sp
3591 .ne 2
3592 .na
3593 \fB\fBM-[Y\fR\fR
3594 .ad
3595 .RS 13n
3596 Move the cursor to the end of line.
3597 .RE
3598 
3599 .sp
3600 .ne 2
3601 .na
3602 \fB\fB^]\fR\fIchar\fR\fR
3603 .ad
3604 .RS 13n
3605 Move the cursor forward to the character \fIchar\fR on the current line.
3606 .RE
3607 
3608 .sp
3609 .ne 2
3610 .na
3611 \fB\fBM-^]\fR\fIchar\fR\fR
3612 .ad
3613 .RS 13n
3614 Move the cursor backwards to the character \fIchar\fR on the current line.
3615 .RE
3616 
3617 .sp
3618 .ne 2
3619 .na
3620 \fB\fB^X^X\fR\fR
3621 .ad
3622 .RS 13n
3623 Interchange the cursor and the mark.
3624 .RE
3625 
3626 .sp
3627 .ne 2
3628 .na
3629 \fB\fIerase\fR\fR
3630 .ad
3631 .RS 13n
3632 Delete the previous character. The user-defined erase character is defined by
3633 the \fBstty\fR(1) command, and is usually \fB^H\fR or \fB#\fR.
3634 .RE
3635 
3636 .sp
3637 .ne 2
3638 .na
3639 \fB\fIlnext\fR\fR
3640 .ad
3641 .RS 13n
3642 Removes the next character's editing features. The user-defined literal next
3643 character is defined by the \fBstty\fR(1) command, or is \fB^V\fR if not
3644 defined.
3645 .RE
3646 
3647 .sp
3648 .ne 2
3649 .na
3650 \fB\fB^D\fR\fR
3651 .ad
3652 .RS 13n
3653 Delete the current character.
3654 .RE
3655 
3656 .sp
3657 .ne 2
3658 .na
3659 \fB\fBM-d\fR\fR
3660 .ad
3661 .RS 13n
3662 Delete the current word.
3663 .RE
3664 
3665 .sp
3666 .ne 2
3667 .na
3668 \fB\fBM-^H\fR\fR
3669 .ad
3670 .RS 13n
3671 MetaBACKSPACE. Delete the previous word.
3672 .RE
3673 
3674 .sp
3675 .ne 2
3676 .na
3677 \fB\fBM-h\fR\fR
3678 .ad
3679 .RS 13n
3680 Delete the previous word.
3681 .RE
3682 
3683 .sp
3684 .ne 2
3685 .na
3686 \fB\fBM-^?\fR\fR
3687 .ad
3688 .RS 13n
3689 MetaDEL. Delete the previous word. If your interrupt character is \fB^?\fR
3690 (DEL, the default), this command does not work.
3691 .RE
3692 
3693 .sp
3694 .ne 2
3695 .na
3696 \fB\fB^T\fR\fR
3697 .ad
3698 .RS 13n
3699 Transpose the current character with the previous character, and advance the
3700 cursor in \fBemacs\fR mode. Transpose two previous characters in \fBgmacs\fR
3701 mode.
3702 .RE
3703 
3704 .sp
3705 .ne 2
3706 .na
3707 \fB\fB^C\fR\fR
3708 .ad
3709 .RS 13n
3710 Capitalize the current character.
3711 .RE
3712 
3713 .sp
3714 .ne 2
3715 .na
3716 \fB\fBM-c\fR\fR
3717 .ad
3718 .RS 13n
3719 Capitalize the current word.
3720 .RE
3721 
3722 .sp
3723 .ne 2
3724 .na
3725 \fB\fBM-l\fR\fR
3726 .ad
3727 .RS 13n
3728 Change the current word to lower case.
3729 .RE
3730 
3731 .sp
3732 .ne 2
3733 .na
3734 \fB\fB^K\fR\fR
3735 .ad
3736 .RS 13n
3737 Delete from the cursor to the end of the line. If preceded by a numerical
3738 parameter whose value is less than the current cursor position, delete from
3739 specified position up to the cursor. If preceded by a numerical parameter whose
3740 value is greater than the current cursor position, then delete from cursor up
3741 to specified cursor position.
3742 .RE
3743 
3744 .sp
3745 .ne 2
3746 .na
3747 \fB\fB^W\fR\fR
3748 .ad
3749 .RS 13n
3750 Kill from the cursor to the mark.
3751 .RE
3752 
3753 .sp
3754 .ne 2
3755 .na
3756 \fB\fBM-p\fR\fR
3757 .ad
3758 .RS 13n
3759 Push the region from the cursor to the mark on the stack.
3760 .RE
3761 
3762 .sp
3763 .ne 2
3764 .na
3765 \fB\fIkill\fR\fR
3766 .ad
3767 .RS 13n
3768 Kill the entire current line. The user-defined kill character is defined by the
3769 \fBstty\fR(1) command, usually a \fB^G\fR or \fB@\fR. If two kill characters
3770 are entered in succession, all kill characters from then on cause a line feed.
3771 This is useful when using paper terminals.
3772 .RE
3773 
3774 .sp
3775 .ne 2
3776 .na
3777 \fB\fB^Y\fR\fR
3778 .ad
3779 .RS 13n
3780 Restore the last item removed from line. Yank the item back to the line.
3781 .RE
3782 
3783 .sp
3784 .ne 2
3785 .na
3786 \fB\fB^L\fR\fR
3787 .ad
3788 .RS 13n
3789 Line feed and print the current line.
3790 .RE
3791 
3792 .sp
3793 .ne 2
3794 .na
3795 \fB\fBM-^L\fR\fR
3796 .ad
3797 .RS 13n
3798 Clear the screen.
3799 .RE
3800 
3801 .sp
3802 .ne 2
3803 .na
3804 \fB\fB^@\fR\fR
3805 .ad
3806 .RS 13n
3807 Null character. Set mark.
3808 .RE
3809 
3810 .sp
3811 .ne 2
3812 .na
3813 \fB\fBM-\fR\fIspace\fR\fR
3814 .ad
3815 .RS 13n
3816 MetaSPACE. Set the mark.
3817 .RE
3818 
3819 .sp
3820 .ne 2
3821 .na
3822 \fB\fB^J\fR\fR
3823 .ad
3824 .RS 13n
3825 New line. Execute the current line.
3826 .RE
3827 
3828 .sp
3829 .ne 2
3830 .na
3831 \fB\fB^M\fR\fR
3832 .ad
3833 .RS 13n
3834 Return. Execute the current line.
3835 .RE
3836 
3837 .sp
3838 .ne 2
3839 .na
3840 \fB\fBEOF\fR\fR
3841 .ad
3842 .RS 13n
3843 End-of-file character, normally \fB^D\fR, is processed as an \fBend-of-file\fR
3844 only if the current line is null.
3845 .RE
3846 
3847 .sp
3848 .ne 2
3849 .na
3850 \fB\fB^P\fR\fR
3851 .ad
3852 .RS 13n
3853 Fetch the previous command. Each time \fB^P\fR is entered the previous command
3854 back in time is accessed. Moves back one line when it is not on the first line
3855 of a multi-line command.
3856 .RE
3857 
3858 .sp
3859 .ne 2
3860 .na
3861 \fB\fBM-[A\fR\fR
3862 .ad
3863 .RS 13n
3864 Equivalent to \fB^P\fR.
3865 .RE
3866 
3867 .sp
3868 .ne 2
3869 .na
3870 \fB\fBM-<\fR\fR
3871 .ad
3872 .RS 13n
3873 Fetch the least recent (oldest) history line.
3874 .RE
3875 
3876 .sp
3877 .ne 2
3878 .na
3879 \fB\fBM->\fR\fR
3880 .ad
3881 .RS 13n
3882 Fetch the most recent (youngest) history line.
3883 .RE
3884 
3885 .sp
3886 .ne 2
3887 .na
3888 \fB\fB^N\fR\fR
3889 .ad
3890 .RS 13n
3891 Fetch the next command line. Each time \fB^N\fR is entered the next command
3892 line forward in time is accessed.
3893 .RE
3894 
3895 .sp
3896 .ne 2
3897 .na
3898 \fB\fBM-[B\fR\fR
3899 .ad
3900 .RS 13n
3901 Equivalent to \fB^N\fR.
3902 .RE
3903 
3904 .sp
3905 .ne 2
3906 .na
3907 \fB\fB^R\fR\fIstring\fR\fR
3908 .ad
3909 .RS 13n
3910 Reverse search history for a previous command line containing \fIstring\fR. If
3911 a parameter of zero is specified, the search is forward. \fIstring\fR is
3912 terminated by a RETURN or NEWLINE. If string is preceded by a \fB^\fR, the
3913 matched line must begin with \fIstring\fR. If \fIstring\fR is omitted, then the
3914 next command line containing the most recent \fIstring\fR is accessed. In this
3915 case a parameter of zero reverses the direction of the search.
3916 .RE
3917 
3918 .sp
3919 .ne 2
3920 .na
3921 \fB\fB^O\fR\fR
3922 .ad
3923 .RS 13n
3924 Operate. Execute the current line and fetch the next line relative to current
3925 line from the history file.
3926 .RE
3927 
3928 .sp
3929 .ne 2
3930 .na
3931 \fB\fBM-\fR\fIdigits\fR\fR
3932 .ad
3933 .RS 13n
3934 Escape. Define numeric parameter. The digits are taken as a parameter to the
3935 next command. The commands that accept a parameter are: \fB^F\fR, \fB^B\fR,
3936 \fBERASE\fR, \fB^C\fR, \fB^D\fR, \fB^K\fR, \fB^R\fR, \fB^P\fR, \fB^N\fR,
3937 \fB^]\fR, \fBM-.\fR, \fBM-\fR, \fBM-^]\fR, \fBM-_\fR, \fBM-=\fR, \fBM-b\fR,
3938 \fBM-c\fR, \fBM-d\fR, \fBM-f\fR, \fBM-h\fR, \fBM-l\fR, and \fBM-^H\fR.
3939 .RE
3940 
3941 .sp
3942 .ne 2
3943 .na
3944 \fB\fBM-\fR\fIletter\fR\fR
3945 .ad
3946 .RS 13n
3947 Soft-key. Search the alias list for an alias by the name \fIletter\fR. If an
3948 alias of \fIletter\fR is defined, insert its value on the input queue.
3949 \fIletter\fR must not be one of the metafunctions in this section.
3950 .RE
3951 
3952 .sp
3953 .ne 2
3954 .na
3955 \fB\fBM-[\fR\fIletter\fR\fR
3956 .ad
3957 .RS 13n
3958 Soft key. Search the alias list for an alias by the name \fIletter\fR. If an
3959 alias of this name is defined, insert its value on the input queue. This can be
3960 used to program function keys on many terminals.
3961 .RE
3962 
3963 .sp
3964 .ne 2
3965 .na
3966 \fB\fBM-.\fR\fR
3967 .ad
3968 .RS 13n
3969 The last word of the previous command is inserted on the line. If preceded by a
3970 numeric parameter, the value of this parameter determines which word to insert
3971 rather than the last word.
3972 .RE
3973 
3974 .sp
3975 .ne 2
3976 .na
3977 \fB\fBM-_\fR\fR
3978 .ad
3979 .RS 13n
3980 Same as \fBM-.\fR.
3981 .RE
3982 
3983 .sp
3984 .ne 2
3985 .na
3986 \fB\fBM-*\fR\fR
3987 .ad
3988 .RS 13n
3989 Attempt filename generation on the current word. As asterisk is appended if the
3990 word does not match any file or contain any special pattern characters.
3991 .RE
3992 
3993 .sp
3994 .ne 2
3995 .na
3996 \fB\fBM-\fRESC\fR
3997 .ad
3998 .RS 13n
3999 Command or file name completion as described in this manual page.
4000 .RE
4001 
4002 .sp
4003 .ne 2
4004 .na
4005 \fB\fB^I\fRTAB\fR
4006 .ad
4007 .RS 13n
4008 Attempts command or file name completion as described in this manual page. If a
4009 partial completion occurs, repeating this behaves as if \fBM-=\fR were entered.
4010 If no match is found or entered after SPACE, a TAB is inserted.
4011 .RE
4012 
4013 .sp
4014 .ne 2
4015 .na
4016 \fB\fBM-=\fR\fR
4017 .ad
4018 .RS 13n
4019 If not preceded by a numeric parameter, generates the list of matching commands
4020 or file names as described in this manual page. Otherwise, the word under the
4021 cursor is replaced by the item corresponding to the value of the numeric
4022 parameter from the most recently generated command or file list. If the cursor
4023 is not on a word, the word is inserted instead.
4024 .RE
4025 
4026 .sp
4027 .ne 2
4028 .na
4029 \fB\fB^U\fR\fR
4030 .ad
4031 .RS 13n
4032 Multiply parameter of next command by \fB4\fR.
4033 .RE
4034 
4035 .sp
4036 .ne 2
4037 .na
4038 \fB\fB\e\fR\fR
4039 .ad
4040 .RS 13n
4041 Escape the next character. Editing characters, the user's erase, kill and
4042 interrupt (normally \fB^?\fR) characters can be entered in a command line or in
4043 a search string if preceded by a \fB\e\fR\&. The \fB\e\fR removes the next
4044 character's editing features, if any.
4045 .RE
4046 
4047 .sp
4048 .ne 2
4049 .na
4050 \fB\fBM-^V\fR\fR
4051 .ad
4052 .RS 13n
4053 Display the version of the shell.
4054 .RE
4055 
4056 .sp
4057 .ne 2
4058 .na
4059 \fB\fBM-#\fR\fR
4060 .ad
4061 .RS 13n
4062 If the line does not begin with a \fB#\fR, a \fB#\fR is inserted at the
4063 beginning of the line and after each NEWLINE, and the line is entered. This
4064 causes a comment to be inserted in the history file. If the line begins with a
4065 \fB#\fR, the \fB#\fR is deleted and one \fB#\fR after each NEWLINE is also
4066 deleted.
4067 .RE
4068 
4069 .SS "\fBvi\fR Editing Mode"
4070 .sp
4071 .LP
4072 There are two typing modes. Initially, when you enter a command you are in the
4073 input mode. To edit, the user enters control mode by typing ESC (033) and moves
4074 the cursor to the point needing correction and then inserts or deletes
4075 characters or words as needed. Most control commands accept an optional repeat
4076 \fIcount\fR prior to the command.
4077 .sp
4078 .LP
4079 When in vi mode on most systems, canonical processing is initially enabled and
4080 the command is echoed again if the speed is 1200 baud or greater and it
4081 contains any control characters or less than one second has elapsed since the
4082 prompt was printed. The ESC character terminates canonical processing for the
4083 remainder of the command and the user can then modify the command line. This
4084 scheme has the advantages of canonical processing with the type-ahead echoing
4085 of raw mode.
4086 .sp
4087 .LP
4088 If the option \fBviraw\fR is also set, the terminal is always have canonical
4089 processing disabled. This mode is implicit for systems that do not support two
4090 alternate end of line delimiters, and might be helpful for certain terminals.
4091 .SS "Input Edit Commands"
4092 .sp
4093 .LP
4094 By default the editor is in input mode.
4095 .sp
4096 .LP
4097 The following input edit commands are supported:
4098 .sp
4099 .ne 2
4100 .na
4101 \fBERASE\fR
4102 .ad
4103 .RS 10n
4104 User defined erase character as defined by the \fBstty\fR command, usually
4105 \fB^H\fR or \fB#\fR. Delete previous character.
4106 .RE
4107 
4108 .sp
4109 .ne 2
4110 .na
4111 \fB\fB^W\fR\fR
4112 .ad
4113 .RS 10n
4114 Delete the previous blank separated word. On some systems the \fBviraw\fR
4115 option might be required for this to work.
4116 .RE
4117 
4118 .sp
4119 .ne 2
4120 .na
4121 \fBEOF\fR
4122 .ad
4123 .RS 10n
4124 As the first character of the line causes the shell to terminate unless the
4125 \fBignoreeof\fR option is set. Otherwise this character is ignored.
4126 .RE
4127 
4128 .sp
4129 .ne 2
4130 .na
4131 \fB\fIlnext\fR\fR
4132 .ad
4133 .RS 10n
4134 User defined literal next character as defined by the \fBstty\fR(1) or \fB^V\fR
4135 if not defined. Removes the next character's editing features, if any. On some
4136 systems the \fBviraw\fR option might be required for this to work.
4137 .RE
4138 
4139 .sp
4140 .ne 2
4141 .na
4142 \fB\fB\e\fR\fR
4143 .ad
4144 .RS 10n
4145 Escape the next ERASE or KILL character.
4146 .RE
4147 
4148 .sp
4149 .ne 2
4150 .na
4151 \fB\fB^I\fR TAB\fR
4152 .ad
4153 .RS 10n
4154 Attempts command or file name completion as described in this manual page and
4155 returns to input mode. If a partial completion occurs, repeating this behaves
4156 as if \fB=\fR were entered from control mode. If no match is found or entered
4157 after SPACE, a TAB is inserted.
4158 .RE
4159 
4160 .SS "Motion Edit Commands"
4161 .sp
4162 .LP
4163 The motion edit commands move the cursor.
4164 .sp
4165 .LP
4166 The following motion edit commands are supported:
4167 .sp
4168 .ne 2
4169 .na
4170 \fB\fB[\fR\fIcount\fR\fB]l\fR\fR
4171 .ad
4172 .RS 13n
4173 Move the cursor forward (right) one character.
4174 .RE
4175 
4176 .sp
4177 .ne 2
4178 .na
4179 \fB\fB[\fR\fIcount\fR\fB][C\fR\fR
4180 .ad
4181 .RS 13n
4182 Move the cursor forward (right) one character.
4183 .RE
4184 
4185 .sp
4186 .ne 2
4187 .na
4188 \fB\fB[\fR\fIcount\fR\fB]w\fR\fR
4189 .ad
4190 .RS 13n
4191 Move the cursor forward one alphanumeric word.
4192 .RE
4193 
4194 .sp
4195 .ne 2
4196 .na
4197 \fB\fB[\fR\fIcount\fR\fB]W\fR\fR
4198 .ad
4199 .RS 13n
4200 Move the cursor to the beginning of the next word that follows a blank.
4201 .RE
4202 
4203 .sp
4204 .ne 2
4205 .na
4206 \fB\fB[\fR\fIcount\fR\fB]e\fR\fR
4207 .ad
4208 .RS 13n
4209 Move the cursor to the end of the word.
4210 .RE
4211 
4212 .sp
4213 .ne 2
4214 .na
4215 \fB\fB[\fR\fIcount\fR\fB]E\fR\fR
4216 .ad
4217 .RS 13n
4218 Move the cursor to the end of the current blank delimited word.
4219 .RE
4220 
4221 .sp
4222 .ne 2
4223 .na
4224 \fB\fB[\fR\fIcount\fR\fB]h\fR\fR
4225 .ad
4226 .RS 13n
4227 Move the cursor backward (left) one character.
4228 .RE
4229 
4230 .sp
4231 .ne 2
4232 .na
4233 \fB\fB[\fR\fIcount\fR\fB][D\fR\fR
4234 .ad
4235 .RS 13n
4236 Move the cursor backward (left) one character.
4237 .RE
4238 
4239 .sp
4240 .ne 2
4241 .na
4242 \fB\fB[\fR\fIcount\fR\fB]b\fR\fR
4243 .ad
4244 .RS 13n
4245 Move the cursor backward one word.
4246 .RE
4247 
4248 .sp
4249 .ne 2
4250 .na
4251 \fB\fB[\fR\fIcount\fR\fB]B\fR\fR
4252 .ad
4253 .RS 13n
4254 Move the cursor to the preceding blank separated word.
4255 .RE
4256 
4257 .sp
4258 .ne 2
4259 .na
4260 \fB\fB[\fR\fIcount\fR\fB]|\fR\fR
4261 .ad
4262 .RS 13n
4263 Move the cursor to column \fIcount\fR.
4264 .RE
4265 
4266 .sp
4267 .ne 2
4268 .na
4269 \fB\fB[\fR\fIcount\fR\fB]f\fR\fIc\fR\fR
4270 .ad
4271 .RS 13n
4272 Find the next character \fIc\fR in the current line.
4273 .RE
4274 
4275 .sp
4276 .ne 2
4277 .na
4278 \fB\fB[\fR\fIcount\fR\fB]F\fR\fIc\fR\fR
4279 .ad
4280 .RS 13n
4281 Find the previous character \fIc\fR in the current line.
4282 .RE
4283 
4284 .sp
4285 .ne 2
4286 .na
4287 \fB\fB[\fR\fIcount\fR\fB]t\fR\fIC\fR\fR
4288 .ad
4289 .RS 13n
4290 Equivalent to \fBf\fR followed by \fBh\fR.
4291 .RE
4292 
4293 .sp
4294 .ne 2
4295 .na
4296 \fB\fB[\fR\fIcount\fR\fB]T\fR\fIc\fR\fR
4297 .ad
4298 .RS 13n
4299 Equivalent to \fBF\fR followed by \fBl\fR.
4300 .RE
4301 
4302 .sp
4303 .ne 2
4304 .na
4305 \fB\fB[\fR\fIcount\fR\fB];\fR\fR
4306 .ad
4307 .RS 13n
4308 Repeat \fIcount\fR times the last single character find command: \fBf\fR,
4309 \fBF\fR, \fBt,\fR or \fBT\fR.
4310 .RE
4311 
4312 .sp
4313 .ne 2
4314 .na
4315 \fB\fB[\fR\fIcount\fR\fB],\fR\fR
4316 .ad
4317 .RS 13n
4318 Reverse the last single character find command \fIcount\fR times.
4319 .RE
4320 
4321 .sp
4322 .ne 2
4323 .na
4324 \fB\fB0\fR\fR
4325 .ad
4326 .RS 13n
4327 Move the cursor to the start of line.
4328 .RE
4329 
4330 .sp
4331 .ne 2
4332 .na
4333 \fB\fB^\fR\fR
4334 .ad
4335 .RS 13n
4336 Move the cursor to start of line.
4337 .RE
4338 
4339 .sp
4340 .ne 2
4341 .na
4342 \fB\fB[H\fR\fR
4343 .ad
4344 .RS 13n
4345 Move the cursor to the first non-blank character in the line.
4346 .RE
4347 
4348 .sp
4349 .ne 2
4350 .na
4351 \fB\fB$\fR\fR
4352 .ad
4353 .RS 13n
4354 Move the cursor to the end of the line.
4355 .RE
4356 
4357 .sp
4358 .ne 2
4359 .na
4360 \fB\fB[Y\fR\fR
4361 .ad
4362 .RS 13n
4363 Move the cursor to the end of the line.
4364 .RE
4365 
4366 .sp
4367 .ne 2
4368 .na
4369 \fB\fB%\fR\fR
4370 .ad
4371 .RS 13n
4372 Moves to balancing \fB(\fR, \fB)\fR, \fB{\fR, \fB}\fR, \fB[\fR, or \fB]\fR. If
4373 cursor is not on one of the characters described in this section, the remainder
4374 of the line is searched for the first occurrence of one of the characters
4375 first.
4376 .RE
4377 
4378 .SS "Search Edit Commands"
4379 .sp
4380 .LP
4381 The search edit commands access your command history.
4382 .sp
4383 .LP
4384 The following search edit commands are supported:
4385 .sp
4386 .ne 2
4387 .na
4388 \fB\fB[\fR\fIcount\fR\fB]k\fR\fR
4389 .ad
4390 .RS 13n
4391 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4392 back in time is accessed.
4393 .RE
4394 
4395 .sp
4396 .ne 2
4397 .na
4398 \fB\fB[\fR\fIcount\fR\fB]-\fR\fR
4399 .ad
4400 .RS 13n
4401 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4402 back in time is accessed.
4403 .sp
4404 Equivalent to \fBk\fR.
4405 .RE
4406 
4407 .sp
4408 .ne 2
4409 .na
4410 \fB\fB[\fR\fIcount\fR\fB][A\fR\fR
4411 .ad
4412 .RS 13n
4413 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4414 back in time is accessed.
4415 .sp
4416 Equivalent to \fBk\fR.
4417 .RE
4418 
4419 .sp
4420 .ne 2
4421 .na
4422 \fB\fB[\fR\fIcount\fR\fB]j\fR\fR
4423 .ad
4424 .RS 13n
4425 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4426 in time is accessed.
4427 .RE
4428 
4429 .sp
4430 .ne 2
4431 .na
4432 \fB\fB[\fR\fIcount\fR\fB]+\fR\fR
4433 .ad
4434 .RS 13n
4435 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4436 in time is accessed.
4437 .sp
4438 Equivalent to \fBj\fR.
4439 .RE
4440 
4441 .sp
4442 .ne 2
4443 .na
4444 \fB\fB[\fR\fIcount\fR\fB][B\fR\fR
4445 .ad
4446 .RS 13n
4447 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4448 in time is accessed.
4449 .sp
4450 Equivalent to \fBj\fR.
4451 .RE
4452 
4453 .sp
4454 .ne 2
4455 .na
4456 \fB\fB[\fR\fIcount\fR\fB]G\fR\fR
4457 .ad
4458 .RS 13n
4459 Fetch command number \fIcount\fR. The default is the least recent history
4460 command.
4461 .RE
4462 
4463 .sp
4464 .ne 2
4465 .na
4466 \fB\fB/\fR\fIstring\fR\fR
4467 .ad
4468 .RS 13n
4469 Search backward through history for a previous command containing \fIstring\fR.
4470 \fIstring\fR is terminated by a RETURN or NEWLINE. If string is preceded by a
4471 \fB^\fR, the matched line must begin with \fIstring\fR. If \fIstring\fR is
4472 null, the previous string is used.
4473 .RE
4474 
4475 .sp
4476 .ne 2
4477 .na
4478 \fB\fB?\fR\fIstring\fR\fR
4479 .ad
4480 .RS 13n
4481 Search forward through history for a previous command containing \fIstring\fR.
4482 \fIstring\fR is terminated by a RETURN or NEWLINE. If string is preceded by a
4483 \fB^\fR, the matched line must begin with \fIstring\fR. If \fIstring\fR is
4484 null, the previous string is used.
4485 .sp
4486 Same as \fI/\fR except that search is in the forward direction.
4487 .RE
4488 
4489 .sp
4490 .ne 2
4491 .na
4492 \fB\fBn\fR\fR
4493 .ad
4494 .RS 13n
4495 Search in the backwards direction for the next match of the last pattern to
4496 \fI/\fR or \fI?\fR commands.
4497 .RE
4498 
4499 .sp
4500 .ne 2
4501 .na
4502 \fB\fBN\fR\fR
4503 .ad
4504 .RS 13n
4505 Search in the forward direction for next match of the last pattern to \fI/\fR
4506 or \fI?\fR.
4507 .RE
4508 
4509 .SS "Text Modification Edit Commands"
4510 .sp
4511 .LP
4512 The following commands modify the line:
4513 .sp
4514 .ne 2
4515 .na
4516 \fB\fBa\fR\fR
4517 .ad
4518 .RS 19n
4519 Enter input mode and enter text after the current character.
4520 .RE
4521 
4522 .sp
4523 .ne 2
4524 .na
4525 \fB\fBA\fR\fR
4526 .ad
4527 .RS 19n
4528 Append text to the end of the line. Equivalent to \fB$a\fR.
4529 .RE
4530 
4531 .sp
4532 .ne 2
4533 .na
4534 \fB\fB[\fR\fIcount\fR\fB]c\fR\fImotion\fR\fR
4535 .ad
4536 .br
4537 .na
4538 \fB\fBc[\fR\fIcount\fR\fB]\fR\fImotion\fR\fR
4539 .ad
4540 .RS 19n
4541 Delete current character through the character that \fImotion\fR would move the
4542 cursor to and enter input mode. If \fImotion\fR is \fBc\fR, the entire line is
4543 deleted and input mode entered.
4544 .RE
4545 
4546 .sp
4547 .ne 2
4548 .na
4549 \fB\fBC\fR\fR
4550 .ad
4551 .RS 19n
4552 Delete the current character through the end of line and enter input mode.
4553 Equivalent to \fBc$\fR.
4554 .RE
4555 
4556 .sp
4557 .ne 2
4558 .na
4559 \fB\fBS\fR\fR
4560 .ad
4561 .RS 19n
4562 Equivalent to \fBcc\fR.
4563 .RE
4564 
4565 .sp
4566 .ne 2
4567 .na
4568 \fB\fB[\fR\fIcount\fR\fB]s\fR\fR
4569 .ad
4570 .RS 19n
4571 Replace characters under the cursor in input mode.
4572 .RE
4573 
4574 .sp
4575 .ne 2
4576 .na
4577 \fB\fBD[\fR\fIcount\fR\fB]d\fR\fImotion\fR\fR
4578 .ad
4579 .RS 19n
4580 Delete the current character through the end of line. Equivalent to d$.
4581 .RE
4582 
4583 .sp
4584 .ne 2
4585 .na
4586 \fB\fBd[\fR\fIcount\fR\fB]\fR\fImotion\fR\fR
4587 .ad
4588 .RS 19n
4589 Delete current character through the character that \fImotion\fR would move to.
4590 If \fImotion\fR is d , the entire line is deleted.
4591 .RE
4592 
4593 .sp
4594 .ne 2
4595 .na
4596 \fB\fBi\fR\fR
4597 .ad
4598 .RS 19n
4599 Enter input mode and insert text before the current character.
4600 .RE
4601 
4602 .sp
4603 .ne 2
4604 .na
4605 \fB\fBI\fR\fR
4606 .ad
4607 .RS 19n
4608 Insert text before the beginning of the line. Equivalent to \fB0i\fR.
4609 .RE
4610 
4611 .sp
4612 .ne 2
4613 .na
4614 \fB\fB[\fR\fIcount\fR\fB]P\fR\fR
4615 .ad
4616 .RS 19n
4617 Place the previous text modification before the cursor.
4618 .RE
4619 
4620 .sp
4621 .ne 2
4622 .na
4623 \fB\fB[\fR\fIcount\fR\fB]p\fR\fR
4624 .ad
4625 .RS 19n
4626 Place the previous text modification after the cursor.
4627 .RE
4628 
4629 .sp
4630 .ne 2
4631 .na
4632 \fB\fBR\fR\fR
4633 .ad
4634 .RS 19n
4635 Enter input mode and replace characters on the screen with characters you type
4636 overlay fashion.
4637 .RE
4638 
4639 .sp
4640 .ne 2
4641 .na
4642 \fB\fB[\fR\fIcount\fR\fB]r\fR\fIc\fR\fR
4643 .ad
4644 .RS 19n
4645 Replace the \fIcount\fR characters starting at the current cursor position with
4646 \fIc\fR, and advance the cursor.
4647 .RE
4648 
4649 .sp
4650 .ne 2
4651 .na
4652 \fB\fB[\fR\fIcount\fR\fB]x\fR\fR
4653 .ad
4654 .RS 19n
4655 Delete current character.
4656 .RE
4657 
4658 .sp
4659 .ne 2
4660 .na
4661 \fB\fB[\fIcount\fR]X\fR\fR
4662 .ad
4663 .RS 19n
4664 Delete preceding character.
4665 .RE
4666 
4667 .sp
4668 .ne 2
4669 .na
4670 \fB\fB[\fIcount\fR].\fR\fR
4671 .ad
4672 .RS 19n
4673 Repeat the previous text modification command.
4674 .RE
4675 
4676 .sp
4677 .ne 2
4678 .na
4679 \fB\fB[\fIcount\fR]~\fR\fR
4680 .ad
4681 .RS 19n
4682 Invert the case of the \fIcount\fR characters starting at the current cursor
4683 position and advance the cursor.
4684 .RE
4685 
4686 .sp
4687 .ne 2
4688 .na
4689 \fB\fB[\fIcount\fR]_\fR\fR
4690 .ad
4691 .RS 19n
4692 Causes the \fIcount\fR word of the previous command to be appended and input
4693 mode entered. The last word is used if \fIcount\fR is omitted.
4694 .RE
4695 
4696 .sp
4697 .ne 2
4698 .na
4699 \fB\fB*\fR\fR
4700 .ad
4701 .RS 19n
4702 Causes an \fB*\fR to be appended to the current word and file name generation
4703 attempted. If no match is found, it rings the bell. Otherwise, the word is
4704 replaced by the matching pattern and input mode is entered.
4705 .RE
4706 
4707 .sp
4708 .ne 2
4709 .na
4710 \fB\fB\e\fR\fR
4711 .ad
4712 .RS 19n
4713 Command or file name completion as described in this manual page.
4714 .RE
4715 
4716 .SS "Other Edit Commands"
4717 .sp
4718 .LP
4719 The following miscellaneous edit commands are supported:
4720 .sp
4721 .ne 2
4722 .na
4723 \fB\fB[\fR\fIcount\fR\fB]y\fR\fImotion\fR\fR
4724 .ad
4725 .br
4726 .na
4727 \fB\fBy[\fR\fIcount\fR\fB]\fR\fImotion\fR\fR
4728 .ad
4729 .RS 18n
4730 Yank the current character through the character to which \fImotion\fR would
4731 move the cursor. Put the yanked characters in the delete buffer. The text and
4732 cursor position are unchanged.
4733 .RE
4734 
4735 .sp
4736 .ne 2
4737 .na
4738 \fB\fByy\fR\fR
4739 .ad
4740 .RS 18n
4741 Yank the current line.
4742 .RE
4743 
4744 .sp
4745 .ne 2
4746 .na
4747 \fB\fBY\fR\fR
4748 .ad
4749 .RS 18n
4750 Yank the current line from the current cursor location to the end of the line.
4751 Equivalent to \fBy$\fR.
4752 .RE
4753 
4754 .sp
4755 .ne 2
4756 .na
4757 \fB\fBu\fR\fR
4758 .ad
4759 .RS 18n
4760 Undo the last text modifying command.
4761 .RE
4762 
4763 .sp
4764 .ne 2
4765 .na
4766 \fB\fBU\fR\fR
4767 .ad
4768 .RS 18n
4769 Undo all the text modifying commands performed on current line.
4770 .RE
4771 
4772 .sp
4773 .ne 2
4774 .na
4775 \fB\fB[\fR\fIcount\fR\fB]V\fR\fR
4776 .ad
4777 .RS 18n
4778 Return the command :
4779 .sp
4780 .in +2
4781 .nf
4782 hist -e ${VISUAL:-${EDITOR:-vi}} \fIcount\fR
4783 .fi
4784 .in -2
4785 .sp
4786 
4787 in the input buffer. If \fIcount\fR is omitted, the current line is used.
4788 .RE
4789 
4790 .sp
4791 .ne 2
4792 .na
4793 \fB\fB^L\fR\fR
4794 .ad
4795 .RS 18n
4796 Line feed and print the current line. This command only works in control mode.
4797 .RE
4798 
4799 .sp
4800 .ne 2
4801 .na
4802 \fB\fB^J\fR\fR
4803 .ad
4804 .RS 18n
4805 New line. Execute the current line, regardless of mode.
4806 .RE
4807 
4808 .sp
4809 .ne 2
4810 .na
4811 \fB\fB^M\fR\fR
4812 .ad
4813 .RS 18n
4814 Return. Execute the current line, regardless of mode.
4815 .RE
4816 
4817 .sp
4818 .ne 2
4819 .na
4820 \fB\fB#\fR\fR
4821 .ad
4822 .RS 18n
4823 If the first character of the command is a \fB#\fR , delete this \fB#\fR and
4824 each \fB#\fR that follows a NEWLINE.
4825 .sp
4826 Otherwise, send the line after inserting a \fB#\fR in front of each line in the
4827 command.
4828 .sp
4829 This is command is useful for causing the current line to be inserted in the
4830 history as a comment and un-commenting previously commented commands in the
4831 history file.
4832 .RE
4833 
4834 .sp
4835 .ne 2
4836 .na
4837 \fB\fB[\fR\fIcount\fR\fB]=\fR\fR
4838 .ad
4839 .RS 18n
4840 If \fIcount\fR is not specified, generate the list of matching commands or file
4841 names as described in this manual page.
4842 .sp
4843 Otherwise, replace the word at the current cursor location with the \fIcount\fR
4844 item from the most recently generated command or file list. If the cursor is
4845 not on a word, it is inserted after the current cursor location.
4846 .RE
4847 
4848 .sp
4849 .ne 2
4850 .na
4851 \fB\fB@\fR\fIletter\fR\fR
4852 .ad
4853 .RS 18n
4854 Search your alias list for an alias by the name \fIletter\fR. If an alias of
4855 this name is defined, insert its value on the input queue for processing.
4856 .RE
4857 
4858 .sp
4859 .ne 2
4860 .na
4861 \fB\fB^V\fR\fR
4862 .ad
4863 .RS 18n
4864 Display version of the shell.
4865 .RE
4866 
4867 .SS "Built-in Commands"
4868 .sp
4869 .LP
4870 The following simple-commands are executed in the shell process. Input and
4871 output redirection is permitted. Unless otherwise indicated, the output is
4872 written on file descriptor \fB1\fR and the exit status, when there is no syntax
4873 error, is \fB0\fR. Except for \fB:\fR, \fBtrue\fR, \fBfalse\fR, \fBecho\fR,
4874 \fBnewgrp\fR, and \fBlogin\fR, all built-in commands accept \fB--\fR to
4875 indicate the end of options. They also interpret the option \fB--man\fR as a
4876 request to display the manual page onto standard error and \fB-?\fR as a help
4877 request which prints a usage message on standard error.
4878 .sp
4879 .LP
4880 Commands that are preceded by one or two \fB++\fR symbols are special built-in
4881 commands and are treated specially in the following ways:
4882 .RS +4
4883 .TP
4884 1.
4885 Variable assignment lists preceding the command remain in effect when the
4886 command completes.
4887 .RE
4888 .RS +4
4889 .TP
4890 2.
4891 I/O redirections are processed after variable assignments.
4892 .RE
4893 .RS +4
4894 .TP
4895 3.
4896 Errors cause a script that contains them to abort.
4897 .RE
4898 .RS +4
4899 .TP
4900 4.
4901 They are not valid function names.
4902 .RE
4903 .RS +4
4904 .TP
4905 5.
4906 Words following a command preceded by \fB++\fR that are in the format of a
4907 variable assignment are expanded with the same rules as a variable assignment.
4908 This means that tilde substitution is performed after the \fB=\fR sign and
4909 field splitting and file name generation are not performed.
4910 .RE
4911 .sp
4912 .ne 2
4913 .na
4914 \fB\fB+ : [\fR\fIarg ...\fR\fB]\fR\fR
4915 .ad
4916 .sp .6
4917 .RS 4n
4918 The command only expands parameters.
4919 .RE
4920 
4921 .sp
4922 .ne 2
4923 .na
4924 \fB\fB+ .\fR \fIname\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
4925 .ad
4926 .sp .6
4927 .RS 4n
4928 If \fIname\fR is a function defined with the \fBfunction\fR \fBname\fR reserved
4929 word syntax, the function is executed in the current environment (as if it had
4930 been defined with the \fIname()\fR syntax.) Otherwise if \fIname\fR refers to a
4931 file, the file is read in its entirety and the commands are executed in the
4932 current shell environment. The search path specified by PATH is used to find
4933 the directory containing the file. If any arguments \fIarg\fR are specified,
4934 they become the positional parameters while processing the . command and the
4935 original positional parameters are restored upon completion. Otherwise the
4936 positional parameters are unchanged. The exit status is the exit status of the
4937 last command executed.
4938 .RE
4939 
4940 .sp
4941 .ne 2
4942 .na
4943 \fB\fB++ alias [\fR\fB-ptx\fR\fB] [\fR\fIname\fR\fB[
4944 =\fR\fIvalue\fR\fB]] ...\fR\fR
4945 .ad
4946 .sp .6
4947 .RS 4n
4948 \fBalias\fR with no arguments prints the list of aliases in the form
4949 \fIname\fR\fB=\fR\fIvalue\fR on standard output. The \fB-p\fR option causes the
4950 word alias to be inserted before each one. When one or more arguments are
4951 specified, an \fIalias\fR is defined for each \fIname\fR whose \fIvalue\fR is
4952 specified. A trailing space in \fIvalue\fR causes the next word to be checked
4953 for alias substitution. The obsolete \fB-t\fR option is used to set and list
4954 tracked aliases. The value of a tracked alias is the full pathname
4955 corresponding to the specified \fIname\fR. The value becomes undefined when the
4956 value of \fBPATH\fR is reset but the alias remains tracked. Without the
4957 \fB-t\fR option, for each \fIname\fR in the argument list for which no
4958 \fIvalue\fR is specified, the name and value of the alias is printed. The
4959 obsolete -x option has no effect. The exit status is \fBnon-zero\fR if a
4960 \fIname\fR is specified, but no value, and no alias has been defined for the
4961 \fIname\fR.
4962 .RE
4963 
4964 .sp
4965 .ne 2
4966 .na
4967 \fB\fBbg [\fR \fIjob\fR\fB\&...]\fR\fR
4968 .ad
4969 .sp .6
4970 .RS 4n
4971 This command is only on systems that support job control. Puts each specified
4972 \fIjob\fR into the background. The current job is put in the background if
4973 \fIjob\fR is not specified. See the \fBJobs\fR section of this manual page for
4974 a description of the format of \fIjob\fR.
4975 .RE
4976 
4977 .sp
4978 .ne 2
4979 .na
4980 \fB\fB+ break [\fR\fIn\fR\fB]\fR\fR
4981 .ad
4982 .sp .6
4983 .RS 4n
4984 Exit from the enclosing \fBfor\fR, \fBwhile\fR, \fBuntil\fR, or \fBselect\fR
4985 loop, if any. If \fIn\fR is specified, then break \fIn\fR levels.
4986 .RE
4987 
4988 .sp
4989 .ne 2
4990 .na
4991 \fB\fBbuiltin [\fR\fB-ds\fR \fB] [\fR\fB-f\fR \fIfile\fR\fB]
4992 [\fR\fIname ...\fR\fB]\fR\fR
4993 .ad
4994 .sp .6
4995 .RS 4n
4996 If \fIname\fR is not specified, and no \fB-f\fR option is specified, the
4997 built-ins are printed on standard output. The \fB-s\fR option prints only the
4998 special built-ins. Otherwise, each \fIname\fR represents the pathname whose
4999 basename is the name of the built-in. The entry point function name is
5000 determined by prepending \fIb\fR to the built-in name. The ISO C/C++ prototype
5001 is \fBb\fR\fImycommand(int argc, char *argv[], void *context)\fR for the
5002 built-in command \fImycommand\fR where \fIargv\fR is an array of \fIargc\fR
5003 elements and \fIcontext\fR is an optional pointer to a \fBShell_t\fR structure
5004 as described in \fB<ast/shell.h>\fR Special built-ins cannot be bound to a
5005 pathname or deleted. The \fB-d\fR option deletes each of the specified
5006 built-ins. On systems that support dynamic loading, the \fB-f\fR option names a
5007 shared library containing the code for built-ins. The shared library prefix
5008 and/or suffix, which depend on the system, can be omitted. Once a library is
5009 loaded, its symbols become available for subsequent invocations of
5010 \fBbuiltin\fR. Multiple libraries can be specified with separate invocations of
5011 the \fBbuiltin\fR command. Libraries are searched in the reverse order in which
5012 they are specified. When a library is loaded, it looks for a function in the
5013 library whose name is \fBlib_init()\fR and invokes this function with an
5014 argument of \fB0\fR.
5015 .RE
5016 
5017 .sp
5018 .ne 2
5019 .na
5020 \fB\fBcd\fR \fB[\fR\fB-LP\fR\fB] [\fR\fIarg\fR\fB]\fR\fR
5021 .ad
5022 .br
5023 .na
5024 \fB\fBcd\fR \fB[\fR\fB-LP\fR\fB]\fR \fIold\fR \fInew\fR\fR
5025 .ad
5026 .sp .6
5027 .RS 4n
5028 This command has two forms.
5029 .sp
5030 In the first form it changes the current directory to \fIarg\fR. If \fIarg\fR
5031 is a \fB-\fR, the directory is changed to the previous directory. The shell
5032 variable \fBHOME\fR is the default \fIarg\fR. The variable \fBPWD\fR is set to
5033 the current directory. The shell variable \fBCDPATH\fR defines the search path
5034 for the directory containing \fIarg\fR. Alternative directory names are
5035 separated by a colon (\fB:\fR). The default path is \fBNULL\fR (specifying the
5036 current directory). The current directory is specified by a null path name,
5037 which can appear immediately after the equal sign or between the colon
5038 delimiters anywhere else in the path list. If \fIarg\fR begins with a \fB/\fR,
5039 the search path is not used. Otherwise, each directory in the path is searched
5040 for \fIarg\fR.
5041 .sp
5042 The second form of \fBcd\fR substitutes the string \fInew\fR for the string
5043 \fIold\fR in the current directory name, \fBPWD\fR, and tries to change to this
5044 new directory. By default, symbolic link names are treated literally when
5045 finding the directory name. This is equivalent to the \fB-L\fR option. The
5046 \fB-P\fR option causes symbolic links to be resolved when determining the
5047 directory. The last instance of \fB-L\fR or \fB-P\fR on the command line
5048 determines which method is used. The \fBcd\fR command cannot be executed by
5049 \fBrksh93\fR.
5050 .RE
5051 
5052 .sp
5053 .ne 2
5054 .na
5055 \fB\fBcommand\fR \fB[\fR\fB-pvVx\fR\fB]\fR \fIname\fR
5056 \fB[\fR\fIarg ...\fR\fB]\fR\fR
5057 .ad
5058 .sp .6
5059 .RS 4n
5060 Without the \fB-v\fR or \fB-V\fR options, executes \fIname\fR with the
5061 arguments specified by \fIarg\fR.
5062 .sp
5063 The \fB-p\fR option causes a default path to be searched rather than the one
5064 defined by the value of \fBPATH\fR. Functions are not searched when finding
5065 \fIname\fR. In addition, if \fIname\fR refers to a special built-in, none of
5066 the special properties associated with the leading daggers are honored. For
5067 example, the predefined alias \fBredirect='command exec'\fR prevents a script
5068 from terminating when an invalid redirection is specified.
5069 .sp
5070 With the \fB-x\fR option, if command execution would result in a failure
5071 because there are too many arguments, \fBerrno E2BIG\fR, the shell invokes
5072 command \fIname\fR multiple times with a subset of the arguments on each
5073 invocation. Arguments that occur prior to the first word that expands to
5074 multiple arguments and after the last word that expands to multiple arguments
5075 are passed on each invocation. The exit status is the maximum invocation exit
5076 status.
5077 .sp
5078 With the \fB-v\fR option, \fBcommand\fR is equivalent to the built-in
5079 \fBwhence\fR command described in this section. The \fB-V\fR option causes
5080 \fBcommand\fR to act like \fBwhence -v\fR.
5081 .RE
5082 
5083 .sp
5084 .ne 2
5085 .na
5086 \fB\fB+continue\fR \fB[\fR\fIn\fR\fB]\fR\fR
5087 .ad
5088 .sp .6
5089 .RS 4n
5090 Resumes the next iteration of the enclosing \fBfor\fR, \fBwhile\fR,
5091 \fBuntil\fR, or \fBselect\fR loop. If \fIn\fR is specified, then resume at the
5092 \fIn\fRth enclosing loop.
5093 .RE
5094 
5095 .sp
5096 .ne 2
5097 .na
5098 \fB\fBdisown\fR \fB[\fR\fIjob...\fR\fB]\fR\fR
5099 .ad
5100 .sp .6
5101 .RS 4n
5102 Causes the shell not to send a \fBHUP\fR signal to each specified \fIjob\fR, or
5103 all active jobs if \fIjob\fR is omitted, when a login shell terminates.
5104 .RE
5105 
5106 .sp
5107 .ne 2
5108 .na
5109 \fB\fBecho\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5110 .ad
5111 .sp .6
5112 .RS 4n
5113 When the first \fIarg\fR does not begin with a \fB-\fR, and none of the
5114 arguments contain a backslash (\fB\e\fR), prints each of its arguments
5115 separated by a SPACE and terminated by a NEWLINE. Otherwise, the behavior of
5116 \fBecho\fR is system dependent and \fBprint\fR or \fBprintf\fR described in
5117 this section should be used. See \fBecho\fR(1) for usage and description.
5118 .RE
5119 
5120 .sp
5121 .ne 2
5122 .na
5123 \fB\fB+eval\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5124 .ad
5125 .sp .6
5126 .RS 4n
5127 The arguments are read as input to the shell and the resulting commands are
5128 executed.
5129 .RE
5130 
5131 .sp
5132 .ne 2
5133 .na
5134 \fB\fB+exec\fR [\fB-c\fR] [\fB-a\fR \fIname ...\fR]
5135 \fB[\fR\fIarg ...\fR\fB]\fR\fR
5136 .ad
5137 .sp .6
5138 .RS 4n
5139 If \fIarg\fR is specified, the command specified by the arguments is executed
5140 in place of this shell without creating a new process. The \fB-c\fR option
5141 causes the environment to be cleared before applying variable assignments
5142 associated with the exec invocation. The \fB-a\fR option causes \fIname\fR
5143 rather than the first \fIarg\fR, to become \fBargv[0]\fR for the new process.
5144 Input and output arguments can appear and affect the current process. If
5145 \fIarg\fR is not specified, the effect of this command is to modify file
5146 descriptors as prescribed by the input/output redirection list. In this case,
5147 any file descriptor numbers greater than \fB2\fR that are opened with this
5148 mechanism are closed when invoking another program.
5149 .RE
5150 
5151 .sp
5152 .ne 2
5153 .na
5154 \fB\fB+exit\fR \fB[\fR\fIn\fR\fB]\fR\fR
5155 .ad
5156 .sp .6
5157 .RS 4n
5158 Causes the shell to exit with the exit status specified by \fIn\fR. The value
5159 is the least significant 8 bits of the specified status. If \fIn\fR is omitted,
5160 then the exit status is that of the last command executed. An end-of-file also
5161 causes the shell to exit except for a shell which has the \fBignoreeof\fR
5162 option turned on. See \fBset\fR.
5163 .RE
5164 
5165 .sp
5166 .ne 2
5167 .na
5168 \fB\fB++export\fR \fB[\fR\fB-p\fR\fB]\fR
5169 \fB[\fR\fIname\fR\fB[=\fR\fIvalue\fR\fB]] ...\fR\fR
5170 .ad
5171 .sp .6
5172 .RS 4n
5173 If \fIname\fR is not specified, the names and values of each variable with the
5174 export attribute are printed with the values quoted in a manner that allows
5175 them to be re-entered. The \fB-p\fR option causes the word export to be
5176 inserted before each one. Otherwise, the specified \fIname\fRs are marked for
5177 automatic export to the environment of subsequently-executed commands.
5178 .RE
5179 
5180 .sp
5181 .ne 2
5182 .na
5183 \fB\fBfalse\fR\fR
5184 .ad
5185 .sp .6
5186 .RS 4n
5187 Does nothing, and exits \fB1\fR. Used with \fBuntil\fR for infinite loops.
5188 .RE
5189 
5190 .sp
5191 .ne 2
5192 .na
5193 \fB\fBfg\fR \fB[\fR\fIjob ...\fR\fB]\fR\fR
5194 .ad
5195 .sp .6
5196 .RS 4n
5197 This command is only on systems that support job control. Each \fIjob\fR
5198 specified is brought to the foreground and waited for in the specified order.
5199 Otherwise, the current job is brought into the foreground. See \fBJobs\fR for a
5200 description of the format of \fIjob\fR.
5201 .RE
5202 
5203 .sp
5204 .ne 2
5205 .na
5206 \fB\fBgetconf\fR \fB[\fR\fIname\fR \fB[\fR\fIpathname\fR\fB]]\fR\fR
5207 .ad
5208 .sp .6
5209 .RS 4n
5210 Prints the current value of the configuration parameter specified by
5211 \fIname\fR. The configuration parameters are defined by the IEEE POSIX 1003.1
5212 and IEEE POSIX 1003.2 standards. See \fBpathconf\fR(2) and \fBsysconf\fR(3C).
5213 .sp
5214 The \fIpathname\fR argument is required for parameters whose value depends on
5215 the location in the file system. If no arguments are specified, \fBgetconf\fR
5216 prints the names and values of the current configuration parameters. The
5217 pathname \fB/\fR is used for each of the parameters that requires
5218 \fIpathname\fR.
5219 .RE
5220 
5221 .sp
5222 .ne 2
5223 .na
5224 \fB\fBgetopts\fR \fB[\fR \fB-a\fR \fIname\fR\fB]\fR \fIoptstring\fR \fIvname\fR
5225 \fB[\fR\fIarg ...\fR\fB]\fR\fR
5226 .ad
5227 .sp .6
5228 .RS 4n
5229 Checks \fIarg\fR for legal options. If \fIarg\fR is omitted, the positional
5230 parameters are used. An option argument begins with a \fB+\fR or a \fB-\fR. An
5231 option that does not begin with \fB+\fR or \fB-\fR or the argument \fB--\fR
5232 ends the options. Options beginning with \fB+\fR are only recognized when
5233 \fIoptstring\fR begins with a \fB+\fR. \fIoptstring\fR contains the letters
5234 that \fBgetopts\fR recognizes. If a letter is followed by a \fB:\fR, that
5235 option is expected to have an argument. The options can be separated from the
5236 argument by blanks. The option \fB-?\fRcauses \fBgetopts\fR to generate a usage
5237 message on standard error. The \fB-a\fR option can be used to specify the name
5238 to use for the usage message, which defaults to $0. \fBgetopts\fR places the
5239 next option letter it finds inside variable \fIvname\fR each time it is
5240 invoked. The option letter is prepended with a \fB+\fR when \fIarg\fR begins
5241 with a \fB+\fR. The index of the next \fIarg\fR is stored in \fBOPTIND\fR. The
5242 option argument, if any, gets stored in \fBOPTARG\fR. A leading : in
5243 \fIoptstring\fR causes \fBgetopts\fR to store the letter of an invalid option
5244 in \fBOPTARG\fR, and to set \fIvname\fR to \fB?\fR for an unknown option and
5245 to: when a required option argument is missing. Otherwise, \fBgetopts\fR prints
5246 an error message. The exit status is \fBnon-zero\fR when there are no more
5247 options. There is no way to specify any of the options \fB:\fR, \fB+\fR,
5248 \fB-\fR, \fB?\fR, \fB[\fR, and \fB]\fR. The option \fB#\fR can only be
5249 specified as the first option.
5250 .RE
5251 
5252 .sp
5253 .ne 2
5254 .na
5255 \fB\fBhist\fR \fB[\fR \fB-e\fR \fIename\fR\fB]\fR\fB[\fR\fB-nlr\fR\fB]\fR
5256 \fB[\fR \fIfirst\fR\fB[\fR\fIlast\fR \fB] ]\fR\fR
5257 .ad
5258 .br
5259 .na
5260 \fB\fR
5261 .ad
5262 .br
5263 .na
5264 \fB\fBhist\fR \fB-s\fR \fB[\fR \fIold\fR\fB=\fR\fInew\fR \fB] [\fR
5265 \fIcommand\fR\fB]\fR\fR
5266 .ad
5267 .sp .6
5268 .RS 4n
5269 In the first form, a range of commands from \fIfirst\fR to \fIlast\fR is
5270 selected from the last \fBHISTSIZE\fR commands that were typed at the terminal.
5271 The arguments \fIfirst\fR and \fIlast\fR can be specified as a number or as a
5272 string. A string is used to locate the most recent command starting with the
5273 specified string. A negative number is used as an offset to the current command
5274 number. If the -l option is selected, the commands are listed on standard
5275 output. Otherwise, the editor program \fIename\fR is invoked on a file
5276 containing these keyboard commands. If \fIename\fR is not supplied, then the
5277 value of the variable \fBHISTEDIT\fR is used. If \fBHISTEDIT\fR is not set,
5278 then \fBFCEDIT\fR (default \fB/bin/ed\fR) is used as the editor. When editing
5279 is complete, the edited command(s) is executed if the changes have been saved.
5280 If \fIlast\fR is not specified, then it is set to \fIfirst\fR. If \fIfirst\fR
5281 is not specified, the default is the previous command for editing and \fB-16\fR
5282 for listing. The option \fB-r\fR reverses the order of the commands and the
5283 option \fB-n\fR suppresses command numbers when listing. In the second form,
5284 \fIcommand\fR is interpreted as \fIfirst\fR described in this section and
5285 defaults to the last command executed. The resulting command is executed after
5286 the optional substitution \fIold\fR\fB=\fR\fInew\fR is performed.
5287 .RE
5288 
5289 .sp
5290 .ne 2
5291 .na
5292 \fB\fBjobs\fR \fB-lnp\fR \fB[\fR\fIjob ...\fR\fB]\fR\fR
5293 .ad
5294 .sp .6
5295 .RS 4n
5296 Lists information about each specified job, or all active jobs if \fIjob\fR is
5297 omitted. The \fB-l\fR option lists process ids in addition to the normal
5298 information. The \fB-n\fR option only displays jobs that have stopped or exited
5299 since last notified. The \fB-p\fR option causes only the process group to be
5300 listed. See \fBJobs\fR for a description of the format of \fIjob\fR.
5301 .RE
5302 
5303 .sp
5304 .ne 2
5305 .na
5306 \fB\fBkill\fR \fB[\fR\fB-s\fR \fIsigname\fR\fB]\fR \fIjob ...\fR\fR
5307 .ad
5308 .br
5309 .na
5310 \fB\fBkill\fR \fB[\fR\fB-n\fR \fIsignum\fR\fB]\fR \fIjob ...\fR\fR
5311 .ad
5312 .br
5313 .na
5314 \fB\fBkill\fR \fB-l\fR \fB[\fR\fIsig ...\fR\fB]\fR\fR
5315 .ad
5316 .sp .6
5317 .RS 4n
5318 Sends either the \fBTERM\fR (terminate) signal or the specified signal to the
5319 specified jobs or processes. Signals are either specified by number with the
5320 \fB-n\fR option or by name with the \fB-s\fR option (as specified in
5321 \fB<signal.h\fR>, stripped of the prefix `\fBSIG\fR with the exception that
5322 \fBSIGCLD\fR is named \fBCHLD\fR). For backward compatibility, the \fBn\fR and
5323 \fBs\fR can be omitted and the number or name placed immediately after the
5324 \fB-\fR. If the signal being sent is \fBTERM\fR (terminate) or \fBHUP\fR (hang
5325 up), then the job or process is sent a \fBCONT\fR (continue) signal if it is
5326 stopped. The argument \fIjob\fR can be the process id of a process that is not
5327 a member of one of the active jobs. See \fBJobs\fR for a description of the
5328 format of \fIjob\fR. In the third form, \fBkill -l\fR, if \fIsig\fR is not
5329 specified, the signal names are listed. Otherwise, for each \fIsig\fR that is a
5330 name, the corresponding signal number is listed. For each \fIsig\fR that is a
5331 number, the signal name corresponding to the least significant 8 bits of
5332 \fIsig\fR is listed.
5333 .RE
5334 
5335 .sp
5336 .ne 2
5337 .na
5338 \fB\fBlet\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5339 .ad
5340 .sp .6
5341 .RS 4n
5342 Each \fIarg\fR is a separate arithmetic expression to be evaluated. See the
5343 \fBArithmetic Evaluation\fR section of this manual page for a description of
5344 arithmetic expression evaluation. The exit status is \fB0\fR if the value of
5345 the last expression is \fBnon-zero\fR, and \fB1\fR otherwise.
5346 .RE
5347 
5348 .sp
5349 .ne 2
5350 .na
5351 \fB\fB+newgrp\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5352 .ad
5353 .sp .6
5354 .RS 4n
5355 Equivalent to \fBexec\fR \fB/bin/newgrp\fR \fIarg ...\fR
5356 .RE
5357 
5358 .sp
5359 .ne 2
5360 .na
5361 \fB\fBprint\fR [\fB-Renprs\fR] \fB[\fR \fB-u\fR \fIunit\fR\fB] [\fR \fB-f\fR
5362 \fIformat\fR \fB] [\fR \fIarg ...\fR\fB]\fR\fR
5363 .ad
5364 .sp .6
5365 .RS 4n
5366 With no options or with option \fB-\fR or \fB--\fR, each \fIarg\fR is printed
5367 on standard output. The \fB-f\fR option causes the arguments to be printed as
5368 described by \fBprintf\fR. In this case, any \fBe\fR, \fBn\fR, \fBr\fR, or
5369 \fBR\fR options are ignored. Otherwise, unless the \fB-R\fR or \fB-r,\fR are
5370 specified, the following escape conventions are applied:
5371 .sp
5372 .ne 2
5373 .na
5374 \fB\fB\ea\fR\fR
5375 .ad
5376 .RS 8n
5377 Alert character (\fBASCII\fR 07)
5378 .RE
5379 
5380 .sp
5381 .ne 2
5382 .na
5383 \fB\fB\eb\fR\fR
5384 .ad
5385 .RS 8n
5386 Backspace character (\fBASCII\fR 010)
5387 .RE
5388 
5389 .sp
5390 .ne 2
5391 .na
5392 \fB\fB\ec\fR\fR
5393 .ad
5394 .RS 8n
5395 Causes print to end without processing more arguments and not adding a NEWLINE
5396 .RE
5397 
5398 .sp
5399 .ne 2
5400 .na
5401 \fB\fB\ef\fR\fR
5402 .ad
5403 .RS 8n
5404 Form-feed character (\fBASCII\fR 014)
5405 .RE
5406 
5407 .sp
5408 .ne 2
5409 .na
5410 \fB\fB\en\fR\fR
5411 .ad
5412 .RS 8n
5413 NEWLINE character (\fBASCII\fR 012)
5414 .RE
5415 
5416 .sp
5417 .ne 2
5418 .na
5419 \fB\fB\er\fR\fR
5420 .ad
5421 .RS 8n
5422 RETURN character (\fBASCII\fR 015)
5423 .RE
5424 
5425 .sp
5426 .ne 2
5427 .na
5428 \fB\fB\et\fR\fR
5429 .ad
5430 .RS 8n
5431 TAB character (\fBASCII\fR 011)
5432 .RE
5433 
5434 .sp
5435 .ne 2
5436 .na
5437 \fB\fB\ev\fR\fR
5438 .ad
5439 .RS 8n
5440 Vertical TAB character (\fBASCII\fR 013)
5441 .RE
5442 
5443 .sp
5444 .ne 2
5445 .na
5446 \fB\fB\eE\fR\fR
5447 .ad
5448 .RS 8n
5449 Escape character (\fBASCII\fR 033)
5450 .RE
5451 
5452 .sp
5453 .ne 2
5454 .na
5455 \fB\fB\e\e\fR\fR
5456 .ad
5457 .RS 8n
5458 Backslash character \fB\e\fR
5459 .RE
5460 
5461 .sp
5462 .ne 2
5463 .na
5464 \fB\fB\e0\fR\fIx\fR\fR
5465 .ad
5466 .RS 8n
5467 Character defined by the 1, 2, or 3-digit octal string specified by \fIx\fR
5468 .RE
5469 
5470 The \fB-R\fR option prints all subsequent arguments and options other than
5471 \fB-n\fR. The \fB-e\fR causes the escape conventions to be applied This is the
5472 default behavior. It reverses the effect of an earlier \fB-r\fR. The \fB-p\fR
5473 option causes the arguments to be written onto the pipe of the process spawned
5474 with \fB|&\fR instead of standard output. The \fB-s\fR option causes the
5475 arguments to be written onto the history file instead of standard output. The
5476 \fB-u\fR option can be used to specify a one digit file descriptor unit number
5477 \fIunit\fR on which the output is placed. The default is \fB1\fR. If the option
5478 \fB-n\fR is used, no NEWLINE is added to the output.
5479 .RE
5480 
5481 .sp
5482 .ne 2
5483 .na
5484 \fB\fBprintf\fR \fIformat\fR\fB[\fR\fIarg ...\fR\fB]\fR\fR
5485 .ad
5486 .sp .6
5487 .RS 4n
5488 The arguments \fIarg\fR are printed on standard output in accordance with the
5489 \fBANSI-C\fR formatting rules associated with the format string \fIformat\fR.
5490 If the number of arguments exceeds the number of format specifications, the
5491 format string is reused to format remaining arguments. The following extensions
5492 can also be used: A \fB%b\fR format can be used instead of \fB%s\fR to cause
5493 escape sequences in the corresponding \fIarg\fR to be expanded as described in
5494 \fBprint\fR. A \fB%B\fR option causes each of the arguments to be treated as
5495 variable names and the binary value of the variables is printed. This is most
5496 useful for variables with an attribute of b. A \fB%H\fR format can be used
5497 instead of \fB%s\fR to cause characters in \fIarg\fR that are special in
5498 \fBHTML\fR and \fBXML\fR to be output as their entity name. A \fB%P\fR format
5499 can be used instead of \fB%s\fR to cause \fIarg\fR to be interpreted as an
5500 extended regular expression and be printed as a shell pattern. A \fB%R\fR
5501 format can be used instead of \fB%s\fR to cause \fIarg\fR to be interpreted as
5502 a shell pattern and to be printed as an extended regular expression. A \fB%q\fR
5503 format can be used instead of \fB%\fRs to cause the resulting string to be
5504 quoted in a manner than can be input again to the shell. A
5505 \fB%(\fR\fIdate-format\fR\fB)T\fR format can be use to treat an argument as a
5506 date/time string and to format the date/time according to the \fIdate-format\fR
5507 as defined for the \fBdate\fR(1) command. A \fB%Z\fR format outputs a byte
5508 whose value is 0. The precision field of the %d format can be followed by a .
5509 and the output base. In this case, the \fB#\fR flag character causes
5510 \fBbase\fR\fI#\fR to be prepended. The \fB#\fR flag when used with the \fBd\fR
5511 specifier without an output base, causes the output to be displayed in
5512 thousands units with one of the suffixes \fBk\fR \fBM\fR \fBG\fR \fBT\fR
5513 \fBP\fR \fBE\fR to indicate the unit. The \fB#\fR flag when used with the i
5514 specifier causes the output to be displayed in \fB1024\fR with one of the
5515 suffixes \fBKi\fR \fBMi\fR \fBGi\fR \fBTi\fR \fBPi\fR \fBEi\fR to indicate the
5516 unit. The \fB=\fR flag has been added to center the output within the specified
5517 field width.
5518 .RE
5519 
5520 .sp
5521 .ne 2
5522 .na
5523 \fB\fBpwd\fR [\fB-LP\fR]\fR
5524 .ad
5525 .sp .6
5526 .RS 4n
5527 Outputs the value of the current working directory. The \fB-L\fR option is the
5528 default. It prints the logical name of the current directory. If the \fB-P\fR
5529 option is specified, all symbolic links are resolved from the name. The last
5530 instance of \fB-L\fR or \fB-P\fR on the command line determines which method is
5531 used.
5532 .RE
5533 
5534 .sp
5535 .ne 2
5536 .na
5537 \fB\fBread\fR \fB[\fR\fB-Aprs\fR\fB] [\fR\fB-d\fR \fIdelim\fR\fB] [\fR \fB-n\fR
5538 \fIn\fR\fB] [[\fR \fB-N\fR \fIn\fR\fB] [[\fR\fB-t\fR \fItimeout\fR\fB]
5539 [\fR\fB-u\fR \fIunit\fR\fB] [\fR\fIvname\fR\fB?\fR\fIprompt\fR\fB] [\fR
5540 \fIvname ...\fR \fB]\fR\fR
5541 .ad
5542 .sp .6
5543 .RS 4n
5544 The shell input mechanism. One line is read and is broken up into fields using
5545 the characters in IFS as separators. The escape character, \fB\e\fR, is used to
5546 remove any special meaning for the next character and for line continuation.
5547 The \fB-d\fR option causes the read to continue to the first character of
5548 \fIdelim\fR rather than \fBNEWLINE\fR. The \fB-n\fR option causes at most
5549 \fIn\fR bytes to read rather a full line but returns when reading from a slow
5550 device as soon as any characters have been read. The \fB-N\fR option causes
5551 exactly \fIn\fR to be read unless an end-of-file has been encountered or the
5552 read times out because of the \fB-t\fR option. In raw mode, \fB-r\fR, the
5553 \fB\e\fR character is not treated specially. The first field is assigned to the
5554 first \fIvname\fR, the second field to the second \fIvname\fR, etc., with
5555 leftover fields assigned to the last \fIvname\fR. When \fIvname\fR has the
5556 binary attribute and \fB-n\fR or \fB-N\fR is specified, the bytes that are read
5557 are stored directly into the variable. If the -v is specified, then the value
5558 of the first \fIvname\fR is used as a default value when reading from a
5559 terminal device. The \fB-A\fR option causes the variable \fIvname\fR to be
5560 unset and each field that is read to be stored in successive elements of the
5561 indexed array \fIvname\fR. The \fB-p\fR option causes the input line to be
5562 taken from the input pipe of a process spawned by the shell using \fB|&\fR. If
5563 the \fB-s\fR option is present, the input is saved as a command in the history
5564 file. The option \fB-u\fR can be used to specify a one digit file descriptor
5565 unit \fIunit\fR to read from. The file descriptor can be opened with the
5566 \fBexec\fR special built-in command. The default value of unit \fIn\fR is
5567 \fB0\fR. The option \fB-t\fR is used to specify a time out in seconds when
5568 reading from a terminal or pipe. If \fIvname\fR is omitted, then REPLY is used
5569 as the default \fIvname\fR. An end-of-file with the \fB-p\fR option causes
5570 cleanup for this process so that another can be spawned. If the first argument
5571 contains a \fB?\fR, the remainder of this word is used as a prompt on standard
5572 error when the shell is interactive. The exit status is \fB0\fR unless an
5573 end-of-file is encountered or read has timed out.
5574 .RE
5575 
5576 .sp
5577 .ne 2
5578 .na
5579 \fB\fB++readonly\fR \fB[\fR\fB-p\fR\fB] [\fR
5580 \fIvname\fR\fB[=\fR\fIvalue\fR\fB]] ...\fR\fR
5581 .ad
5582 .sp .6
5583 .RS 4n
5584 If \fIvname\fR is not specified, the names and values of each variable with the
5585 read-only attribute is printed with the values quoted in a manner that allows
5586 them to be input again. The \fB-p\fR option causes the word \fBreadonly\fR to
5587 be inserted before each one. Otherwise, the specified \fIvname\fRs are marked
5588 \fBreadonly\fR and these names cannot be changed by subsequent assignment.
5589 .RE
5590 
5591 .sp
5592 .ne 2
5593 .na
5594 \fB\fB+return\fR \fB[\fR\fIn\fR\fB]\fR\fR
5595 .ad
5596 .sp .6
5597 .RS 4n
5598 Causes a shell function or script to return to the invoking script with the
5599 exit status specified by \fIn\fR. The value is the least significant 8 bits of
5600 the specified status. If \fBn\fR is omitted, then the return status is that of
5601 the last command executed. If return is invoked while not in a function or a
5602 script, then it behaves the same as exit.
5603 .RE
5604 
5605 .sp
5606 .ne 2
5607 .na
5608 \fB\fB+set [ \(+-BCGabefhkmnoprstuvx] [\(+-o [\fR \fIoption\fR \fB] ] ... [
5609 \(+-A\fR \fIvname\fR\fB]\fR \fB[\fR\fIarg...\fR\fB]\fR\fR
5610 .ad
5611 .sp .6
5612 .RS 4n
5613 The \fBset\fR command supports the following options:
5614 .sp
5615 .ne 2
5616 .na
5617 \fB\fB-a\fR\fR
5618 .ad
5619 .sp .6
5620 .RS 4n
5621 All subsequent variables that are defined are automatically exported.
5622 .RE
5623 
5624 .sp
5625 .ne 2
5626 .na
5627 \fB\fB-A\fR\fR
5628 .ad
5629 .sp .6
5630 .RS 4n
5631 Array assignment. Unset the variable \fIvname\fR and assign values sequentially
5632 from the \fIarg\fR list. If \fB+A\fR is used, the variable \fIvname\fR is not
5633 unset first.
5634 .RE
5635 
5636 .sp
5637 .ne 2
5638 .na
5639 \fB\fB-b\fR\fR
5640 .ad
5641 .sp .6
5642 .RS 4n
5643 Prints job completion messages as soon as a background job changes state rather
5644 than waiting for the next prompt.
5645 .RE
5646 
5647 .sp
5648 .ne 2
5649 .na
5650 \fB\fB-B\fR\fR
5651 .ad
5652 .sp .6
5653 .RS 4n
5654 Enable brace pattern field generation. This is the default behavior.
5655 .RE
5656 
5657 .sp
5658 .ne 2
5659 .na
5660 \fB\fB-C\fR\fR
5661 .ad
5662 .sp .6
5663 .RS 4n
5664 Prevents redirection (\fB>\fR) from truncating existing files. Files that are
5665 created are opened with the \fBO_EXCL\fR mode. Requires \fB>|\fR to truncate a
5666 file when turned on.
5667 .RE
5668 
5669 .sp
5670 .ne 2
5671 .na
5672 \fB\fB-e\fR\fR
5673 .ad
5674 .sp .6
5675 .RS 4n
5676 If a command has a \fBnon-zero\fR exit status, execute the \fBERR\fR trap, if
5677 set, and exit. This mode is disabled while reading profiles.
5678 .RE
5679 
5680 .sp
5681 .ne 2
5682 .na
5683 \fB\fB-f\fR\fR
5684 .ad
5685 .sp .6
5686 .RS 4n
5687 Disables file name generation.
5688 .RE
5689 
5690 .sp
5691 .ne 2
5692 .na
5693 \fB\fB-G\fR\fR
5694 .ad
5695 .sp .6
5696 .RS 4n
5697 Causes the pattern \fB**\fR by itself to match files and zero or more
5698 directories and subdirectories when used for file name generation. If followed
5699 by a \fB/\fR only directories and subdirectories are matched.
5700 .RE
5701 
5702 .sp
5703 .ne 2
5704 .na
5705 \fB\fB-h\fR\fR
5706 .ad
5707 .sp .6
5708 .RS 4n
5709 Each command becomes a tracked alias when first encountered.
5710 .RE
5711 
5712 .sp
5713 .ne 2
5714 .na
5715 \fB\fB-k\fR\fR
5716 .ad
5717 .sp .6
5718 .RS 4n
5719 Obsolete. All variable assignment arguments are placed in the environment for a
5720 command, not just those that precede the command name.
5721 .RE
5722 
5723 .sp
5724 .ne 2
5725 .na
5726 \fB\fB-m\fR\fR
5727 .ad
5728 .sp .6
5729 .RS 4n
5730 Background jobs run in a separate process group and a line prints upon
5731 completion. The exit status of background jobs is reported in a completion
5732 message. On systems with job control, this option is turned on automatically
5733 for interactive shells.
5734 .RE
5735 
5736 .sp
5737 .ne 2
5738 .na
5739 \fB\fB-n\fR\fR
5740 .ad
5741 .sp .6
5742 .RS 4n
5743 Read commands and check them for syntax errors, but do not execute them.
5744 Ignored for interactive shells.
5745 .RE
5746 
5747 .sp
5748 .ne 2
5749 .na
5750 \fB\fB-o\fR\fR
5751 .ad
5752 .sp .6
5753 .RS 4n
5754 If no option name is supplied, the list of options and their current settings
5755 are written to standard output. When invoked with a \fB+\fR, the options are
5756 written in a format that can be input again to the shell to restore the
5757 settings. This option can be repeated to enable or disable multiple options.
5758 .sp
5759 The following argument can be one of the following option names:
5760 .sp
5761 .ne 2
5762 .na
5763 \fB\fBallexport\fR\fR
5764 .ad
5765 .sp .6
5766 .RS 4n
5767 Same as \fB-a\fR.
5768 .RE
5769 
5770 .sp
5771 .ne 2
5772 .na
5773 \fB\fBbgnice\fR\fR
5774 .ad
5775 .sp .6
5776 .RS 4n
5777 All background jobs are run at a lower priority. This is the default mode.
5778 .RE
5779 
5780 .sp
5781 .ne 2
5782 .na
5783 \fB\fBbraceexpand\fR\fR
5784 .ad
5785 .sp .6
5786 .RS 4n
5787 Same as \fB-\fRB.
5788 .RE
5789 
5790 .sp
5791 .ne 2
5792 .na
5793 \fB\fBemacs\fR\fR
5794 .ad
5795 .sp .6
5796 .RS 4n
5797 Puts you in an \fBemacs\fR style inline editor for command entry.
5798 .RE
5799 
5800 .sp
5801 .ne 2
5802 .na
5803 \fB\fBerrexit\fR\fR
5804 .ad
5805 .sp .6
5806 .RS 4n
5807 Same as \fB-e\fR.
5808 .RE
5809 
5810 .sp
5811 .ne 2
5812 .na
5813 \fB\fBglobstar\fR\fR
5814 .ad
5815 .sp .6
5816 .RS 4n
5817 Same as \fB-G\fR.
5818 .RE
5819 
5820 .sp
5821 .ne 2
5822 .na
5823 \fB\fBgmacs\fR\fR
5824 .ad
5825 .sp .6
5826 .RS 4n
5827 Puts you in a \fBgmacs\fR style inline editor for command entry.
5828 .RE
5829 
5830 .sp
5831 .ne 2
5832 .na
5833 \fB\fBignoreeof\fR\fR
5834 .ad
5835 .sp .6
5836 .RS 4n
5837 The shell does not exit on end-of-file. The command \fBexit\fR must be used.
5838 .RE
5839 
5840 .sp
5841 .ne 2
5842 .na
5843 \fB\fBkeyword\fR\fR
5844 .ad
5845 .sp .6
5846 .RS 4n
5847 Same as \fB-k\fR.
5848 .RE
5849 
5850 .sp
5851 .ne 2
5852 .na
5853 \fB\fBmarkdirs\fR\fR
5854 .ad
5855 .sp .6
5856 .RS 4n
5857 All directory names resulting from file name generation have a trailing /
5858 appended.
5859 .RE
5860 
5861 .sp
5862 .ne 2
5863 .na
5864 \fB\fBmonitor\fR\fR
5865 .ad
5866 .sp .6
5867 .RS 4n
5868 Same as \fB-m\fR.
5869 .RE
5870 
5871 .sp
5872 .ne 2
5873 .na
5874 \fB\fBmultiline\fR\fR
5875 .ad
5876 .sp .6
5877 .RS 4n
5878 The built-in editors use multiple lines on the screen for lines that are longer
5879 than the width of the screen. This might not work for all terminals.
5880 .RE
5881 
5882 .sp
5883 .ne 2
5884 .na
5885 \fB\fBnoclobber\fR\fR
5886 .ad
5887 .sp .6
5888 .RS 4n
5889 Same as \fB-C\fR.
5890 .RE
5891 
5892 .sp
5893 .ne 2
5894 .na
5895 \fB\fBnoexec\fR\fR
5896 .ad
5897 .sp .6
5898 .RS 4n
5899 Same as \fB-n\fR.
5900 .RE
5901 
5902 .sp
5903 .ne 2
5904 .na
5905 \fB\fBnoglob\fR\fR
5906 .ad
5907 .sp .6
5908 .RS 4n
5909 Same as \fB-f\fR.
5910 .RE
5911 
5912 .sp
5913 .ne 2
5914 .na
5915 \fB\fBnolog\fR\fR
5916 .ad
5917 .sp .6
5918 .RS 4n
5919 Do not save function definitions in the history file.
5920 .RE
5921 
5922 .sp
5923 .ne 2
5924 .na
5925 \fB\fBnotify\fR\fR
5926 .ad
5927 .sp .6
5928 .RS 4n
5929 Same as \fB-b\fR.
5930 .RE
5931 
5932 .sp
5933 .ne 2
5934 .na
5935 \fB\fBnounset\fR\fR
5936 .ad
5937 .sp .6
5938 .RS 4n
5939 Same as \fB-u\fR.
5940 .RE
5941 
5942 .sp
5943 .ne 2
5944 .na
5945 \fB\fBpipefail\fR\fR
5946 .ad
5947 .sp .6
5948 .RS 4n
5949 A pipeline does not complete until all components of the pipeline have
5950 completed, and the return value is the value of the last \fBnon-zero\fR command
5951 to fail or zero if no command has failed.
5952 .RE
5953 
5954 .sp
5955 .ne 2
5956 .na
5957 \fB\fBprivileged\fR\fR
5958 .ad
5959 .sp .6
5960 .RS 4n
5961 Same as \fB-p\fR.
5962 .RE
5963 
5964 .sp
5965 .ne 2
5966 .na
5967 \fB\fBshowme\fR\fR
5968 .ad
5969 .sp .6
5970 .RS 4n
5971 When enabled, simple commands or pipelines preceded by a a semicolon (\fB;\fR)
5972 is displayed as if the \fBxtrace\fR option were enabled but is not executed.
5973 Otherwise, the leading \fB;\fR is ignored.
5974 .RE
5975 
5976 .sp
5977 .ne 2
5978 .na
5979 \fB\fBtrackall\fR\fR
5980 .ad
5981 .sp .6
5982 .RS 4n
5983 Same as \fB-h\fR.
5984 .RE
5985 
5986 .sp
5987 .ne 2
5988 .na
5989 \fB\fBverbose\fR\fR
5990 .ad
5991 .sp .6
5992 .RS 4n
5993 Same as \fB-v\fR.
5994 .RE
5995 
5996 .sp
5997 .ne 2
5998 .na
5999 \fB\fBvi\fR\fR
6000 .ad
6001 .sp .6
6002 .RS 4n
6003 Puts you in insert mode of a \fBvi\fR style inline editor until you hit the
6004 escape character 033. This puts you in control mode. A return sends the line.
6005 .RE
6006 
6007 .sp
6008 .ne 2
6009 .na
6010 \fB\fBviraw\fR\fR
6011 .ad
6012 .sp .6
6013 .RS 4n
6014 Each character is processed as it is typed in \fBvi\fR mode.
6015 .RE
6016 
6017 .sp
6018 .ne 2
6019 .na
6020 \fB\fBxtrace\fR\fR
6021 .ad
6022 .sp .6
6023 .RS 4n
6024 Same as \fB-x\fR.
6025 .sp
6026 If no option name is supplied, the current options settings are printed.
6027 .RE
6028 
6029 .RE
6030 
6031 .sp
6032 .ne 2
6033 .na
6034 \fB\fB-p\fR\fR
6035 .ad
6036 .sp .6
6037 .RS 4n
6038 Disables processing of the \fB$HOME/.profile\fR file and uses the file
6039 \fB/etc/suid_profile\fR instead of the \fBENV\fR file. This mode is on whenever
6040 the effective \fBuid\fR (\fBgid\fR) is not equal to the real \fBuid\fR
6041 (\fBgid\fR). Turning this off causes the effective \fBuid\fR and \fBgid\fR to
6042 be set to the real \fBuid\fR and \fBgid\fR.
6043 .RE
6044 
6045 .sp
6046 .ne 2
6047 .na
6048 \fB\fB-r\fR\fR
6049 .ad
6050 .sp .6
6051 .RS 4n
6052 Enables the restricted shell. This option cannot be unset once set.
6053 .RE
6054 
6055 .sp
6056 .ne 2
6057 .na
6058 \fB\fB-s\fR\fR
6059 .ad
6060 .sp .6
6061 .RS 4n
6062 Sort the positional parameters lexicographically.
6063 .RE
6064 
6065 .sp
6066 .ne 2
6067 .na
6068 \fB\fB-t\fR\fR
6069 .ad
6070 .sp .6
6071 .RS 4n
6072 Obsolete. Exit after reading and executing one command.
6073 .RE
6074 
6075 .sp
6076 .ne 2
6077 .na
6078 \fB\fB-u\fR\fR
6079 .ad
6080 .sp .6
6081 .RS 4n
6082 Treat \fBunset\fR parameters as an error when substituting.
6083 .RE
6084 
6085 .sp
6086 .ne 2
6087 .na
6088 \fB\fB-v\fR\fR
6089 .ad
6090 .sp .6
6091 .RS 4n
6092 Print shell input lines as they are read.
6093 .RE
6094 
6095 .sp
6096 .ne 2
6097 .na
6098 \fB\fB-x\fR\fR
6099 .ad
6100 .sp .6
6101 .RS 4n
6102 Print commands and their arguments as they are executed.
6103 .RE
6104 
6105 .sp
6106 .ne 2
6107 .na
6108 \fB\fB--\fR\fR
6109 .ad
6110 .sp .6
6111 .RS 4n
6112 Do not change any of the options. This is useful in setting \fB$1\fR to a value
6113 beginning with \fB-\fR. If no arguments follow this option then the positional
6114 parameters are unset.
6115 .RE
6116 
6117 As an obsolete feature, if the first \fIarg\fR is - then the \fB-x\fR and
6118 \fB-v\fR options are turned off and the next \fIarg\fR is treated as the first
6119 argument. Using \fB+\fR rather than \fB-\fR causes these options to be turned
6120 off. These options can also be used upon invocation of the shell. The current
6121 set of options can be found in \fB$-\fR. Unless \fB-A\fR is specified, the
6122 remaining arguments are positional parameters and are assigned, in order, to
6123 \fB$1 $2 \&....\fR If no arguments are specified, then the names and values of
6124 all variables are printed on the standard output.
6125 .RE
6126 
6127 .sp
6128 .ne 2
6129 .na
6130 \fB\fB+shift\fR \fB[\fR\fIn\fR\fB]\fR\fR
6131 .ad
6132 .sp .6
6133 .RS 4n
6134 The positional parameters from \fB$\fR\fIn\fR\fB+1 ...\fR are renamed
6135 \fB$1 ...\fR, the default \fIn\fR is \fB1\fR. The parameter \fIn\fR can be any
6136 arithmetic expression that evaluates to a non-negative number less than or
6137 equal to \fB$#\fR.
6138 .RE
6139 
6140 .sp
6141 .ne 2
6142 .na
6143 \fB\fBsleep\fR \fIseconds\fR\fR
6144 .ad
6145 .sp .6
6146 .RS 4n
6147 Suspends execution for the number of decimal seconds or fractions of a second
6148 specified by \fIseconds\fR.
6149 .RE
6150 
6151 .sp
6152 .ne 2
6153 .na
6154 \fB\fB+trap\fR \fB-p\fR \fB[\fR\fIaction\fR\fB]\fR
6155 \fB[\fR\fIsig\fR\fB] ...\fR\fR
6156 .ad
6157 .sp .6
6158 .RS 4n
6159 The \fB-p\fR option causes the trap action associated with each trap as
6160 specified by the arguments to be printed with appropriate quoting. Otherwise,
6161 \fIaction\fR is processed as if it were an argument to \fBeval\fR when the
6162 shell receives signal(s) \fIsig\fR. Each \fIsig\fR can be specified as a number
6163 or as the name of the signal. Trap commands are executed in order of signal
6164 number. Any attempt to set a trap on a signal that was ignored on entry to the
6165 current shell is ineffective. If \fIaction\fR is omitted and the first
6166 \fIsig\fR is a number, or if \fIaction\fR is \fB-\fR, then the trap(s) for each
6167 \fIsig\fR are reset to their original values. If \fIaction\fR is the null
6168 string then this signal is ignored by the shell and by the commands it invokes.
6169 If \fIsig\fR is \fBERR\fR then \fIaction\fR is executed whenever a command has
6170 a \fBnon-zero\fR exit status. If \fIsig\fR is \fBDEBUG\fR then \fIaction\fR is
6171 executed before each command. The variable \fB\&.sh.command\fR contains the
6172 contents of the current command line when \fIaction\fR is running. If \fIsig\fR
6173 is \fB0\fR or \fBEXIT\fR and the trap statement is executed inside the body of
6174 a function defined with the \fBfunction\fR \fIname\fR syntax, then the command
6175 \fIaction\fR is executed after the function completes. If \fIsig\fR is \fB0\fR
6176 or \fBEXIT\fR for a trap set outside any function then the command \fIaction\fR
6177 is executed on exit from the shell. If \fIsig\fR is \fBKEYBD\fR, then
6178 \fIaction\fR is executed whenever a key is read while in \fBemacs\fR,
6179 \fBgmacs\fR, or \fBvi\fR mode. The \fBtrap\fR command with no arguments prints
6180 a list of commands associated with each signal number.
6181 .RE
6182 
6183 .sp
6184 .ne 2
6185 .na
6186 \fB\fBtrue\fR\fR
6187 .ad
6188 .sp .6
6189 .RS 4n
6190 Does nothing, and exits \fB0\fR. Used with while for infinite loops.
6191 .RE
6192 
6193 .sp
6194 .ne 2
6195 .na
6196 \fB\fB++typeset [\(+-AHflabnprtux ] [ \(+-EFLRZi[\fR\fIn\fR\fB] ] [\fR
6197 \fIvname\fR\fB[=\fR\fIvalue\fR \fB] ]\fR\fR
6198 .ad
6199 .sp .6
6200 .RS 4n
6201 Sets attributes and values for shell variables and functions. When invoked
6202 inside a function defined with the \fBfunction\fR \fIname\fR syntax, a new
6203 instance of the variable \fIvname\fR is created, and the variable's value and
6204 type are restored when the function completes.
6205 .sp
6206 Using \fB+\fR rather than \fB-\fR causes these options to be turned off. If no
6207 \fIvname\fR arguments are specified, a list of \fIvname\fRs (and optionally the
6208 \fIvalue\fRs) of the variables is printed. Using \fB+\fR rather than \fB-\fR
6209 keeps the values from being printed.) The \fB-p\fR option causes \fBtypeset\fR
6210 followed by the option letters to be printed before each name rather than the
6211 names of the options. If any option other than \fB-p\fR is specified, only
6212 those variables which have all of the specified options are printed. Otherwise,
6213 the \fIvname\fRs and \fIattributes\fR of all variables that have attributes are
6214 printed.
6215 .sp
6216 The following list of attributes can be specified:
6217 .sp
6218 .ne 2
6219 .na
6220 \fB\fB-a\fR\fR
6221 .ad
6222 .RS 6n
6223 Declares \fIvname\fR to be an indexed array. This is optional unless except for
6224 compound variable assignments.
6225 .RE
6226 
6227 .sp
6228 .ne 2
6229 .na
6230 \fB\fB-A\fR\fR
6231 .ad
6232 .RS 6n
6233 Declares \fIvname\fR to be an associative array. Sub-scripts are strings rather
6234 than arithmetic expressions.
6235 .RE
6236 
6237 .sp
6238 .ne 2
6239 .na
6240 \fB\fB-b\fR\fR
6241 .ad
6242 .RS 6n
6243 The variable can hold any number of bytes of data. The data can be text or
6244 binary. The value is represented by the \fBbase64\fR encoding of the data. If
6245 \fB-Z\fR is also specified, the size in bytes of the data in the buffer is
6246 determined by the size associated with the \fB-Z\fR. If the \fBbase64\fR string
6247 assigned results in more data, it is truncated. Otherwise, it is filled with
6248 bytes whose value is zero. The \fBprintf\fR format \fB%B\fR can be used to
6249 output the actual data in this buffer instead of the \fBbase64\fR encoding of
6250 the data.
6251 .RE
6252 
6253 .sp
6254 .ne 2
6255 .na
6256 \fB\fB-E\fR\fR
6257 .ad
6258 .RS 6n
6259 Declares \fIvname\fR to be a double precision floating point number. If \fIn\fR
6260 is \fBnon-zero\fR, it defines the number of significant figures that are used
6261 when expanding \fIvname\fR. Otherwise, ten significant figures is used.
6262 .RE
6263 
6264 .sp
6265 .ne 2
6266 .na
6267 \fB\fB-f\fR\fR
6268 .ad
6269 .RS 6n
6270 The names refer to function names rather than variable names. No assignments
6271 can be made and the only other valid options are \fB-t\fR, \fB-u\fR, and
6272 \fB-x.\fR The \fB-t\fR option turns on execution tracing for this function. The
6273 \fB-u\fR option causes this function to be marked undefined. The \fBFPATH\fR
6274 variable is searched to find the function definition when the function is
6275 referenced. If no options other than \fB-f\fR is specified, then the function
6276 definition is displayed on standard output. If \fB+f\fR is specified, then a
6277 line containing the function name followed by a shell comment containing the
6278 line number and path name of the file where this function was defined, if any,
6279 is displayed.
6280 .sp
6281 The \fB-i\fR attribute cannot be specified with \fB-f\fR.
6282 .RE
6283 
6284 .sp
6285 .ne 2
6286 .na
6287 \fB\fB-F\fR\fR
6288 .ad
6289 .RS 6n
6290 Declares \fIvname\fR to be a double precision floating point number. If \fIn\fR
6291 is \fBnon-zero\fR, it defines the number of places after the decimal point that
6292 are used when expanding \fIvname\fR. Otherwise ten places after the decimal
6293 point is used.
6294 .RE
6295 
6296 .sp
6297 .ne 2
6298 .na
6299 \fB\fB-H\fR\fR
6300 .ad
6301 .RS 6n
6302 This option provides UNIX to hostname file mapping on non-UNIX machines.
6303 .RE
6304 
6305 .sp
6306 .ne 2
6307 .na
6308 \fB\fB-i\fR\fR
6309 .ad
6310 .RS 6n
6311 Declares \fIvname\fR to be represented internally as integer. The right hand
6312 side of an assignment is evaluated as an arithmetic expression when assigning
6313 to an integer. If \fIn\fR is \fBnon-zero\fR, it defines the output arithmetic
6314 base, otherwise the output base is ten.
6315 .sp
6316 The \fB-i\fR attribute cannot be specified along with \fB-R\fR, \fB-L\fR,
6317 \fB-Z\fR, or \fB-f\fR.
6318 .RE
6319 
6320 .sp
6321 .ne 2
6322 .na
6323 \fB\fB-l\fR\fR
6324 .ad
6325 .RS 6n
6326 All uppercase characters are converted to lowercase. The uppercase option,
6327 \fB-u\fR, is turned off.
6328 .RE
6329 
6330 .sp
6331 .ne 2
6332 .na
6333 \fB\fB-L\fR\fR
6334 .ad
6335 .RS 6n
6336 Left justify and remove leading blanks from \fIvalue\fR. If \fIn\fR is
6337 \fBnon-zero\fR, it defines the width of the field, otherwise it is determined
6338 by the width of the value of first assignment. When the variable is assigned
6339 to, it is filled on the right with blanks or truncated, if necessary, to fit
6340 into the field. The \fB-R\fR option is turned off.
6341 .sp
6342 The \fB-i\fR attribute cannot be specified with \fB-L\fR.
6343 .RE
6344 
6345 .sp
6346 .ne 2
6347 .na
6348 \fB\fB-n\fR\fR
6349 .ad
6350 .RS 6n
6351 Declares \fIvname\fR to be a reference to the variable whose name is defined by
6352 the value of variable \fIvname\fR. This is usually used to reference a variable
6353 inside a function whose name has been passed as an argument.
6354 .RE
6355 
6356 .sp
6357 .ne 2
6358 .na
6359 \fB\fB-R\fR\fR
6360 .ad
6361 .RS 6n
6362 Right justify and fill with leading blanks. If \fIn\fR is \fBnon-zero\fR, it
6363 defines the width of the field, otherwise it is determined by the width of the
6364 value of first assignment. The field is left filled with blanks or truncated
6365 from the end if the variable is reassigned. The \fB-L\fR option is turned off.
6366 .sp
6367 The \fB-i\fR attribute cannot be specified with \fB-R\fR.
6368 .RE
6369 
6370 .sp
6371 .ne 2
6372 .na
6373 \fB\fB-r\fR\fR
6374 .ad
6375 .RS 6n
6376 The specified \fIvname\fRs are marked read-only and these names cannot be
6377 changed by subsequent assignment.
6378 .RE
6379 
6380 .sp
6381 .ne 2
6382 .na
6383 \fB\fB-t\fR\fR
6384 .ad
6385 .RS 6n
6386 Tags the variables. Tags are user definable and have no special meaning to the
6387 shell.
6388 .RE
6389 
6390 .sp
6391 .ne 2
6392 .na
6393 \fB\fB-u\fR\fR
6394 .ad
6395 .RS 6n
6396 All lowercase characters are converted to uppercase. The lowercase option,
6397 \fB-l\fR, is turned off.
6398 .RE
6399 
6400 .sp
6401 .ne 2
6402 .na
6403 \fB\fB-x\fR\fR
6404 .ad
6405 .RS 6n
6406 The specified \fIvname\fRs are marked for automatic export to the environment
6407 of subsequently-executed commands. Variables whose names contain a . cannot be
6408 exported.
6409 .RE
6410 
6411 .sp
6412 .ne 2
6413 .na
6414 \fB\fB-Z\fR\fR
6415 .ad
6416 .RS 6n
6417 Right justify and fill with leading zeros if the first non-blank character is a
6418 digit and the \fB-L\fR option has not been set. Remove leading zeros if the
6419 \fB-L\fR option is also set. If \fIn\fR is \fBnon-zero\fR, it defines the width
6420 of the field, otherwise it is determined by the width of the value of first
6421 assignment.
6422 .sp
6423 The \fB-i\fR attribute cannot be specified with \fB-Z\fR.
6424 .RE
6425 
6426 .RE
6427 
6428 .sp
6429 .ne 2
6430 .na
6431 \fB\fBulimit [\fR\fB-HSacdfmnpstv\fR\fB] [\fR \fIlimit\fR\fB]\fR\fR
6432 .ad
6433 .sp .6
6434 .RS 4n
6435 Set or display a resource limit. Many systems do not support one or more of
6436 these limits. The limit for a specified resource is set when \fIlimit\fR is
6437 specified. The value of \fIlimit\fR can be a number in the unit specified with
6438 each resource, or the value unlimited. When more than one resource is
6439 specified, then the limit name and unit is printed before the value.
6440 .sp
6441 If no option is specified, \fB-f\fR is assumed.
6442 .sp
6443 The following are the available resource limits:
6444 .sp
6445 .ne 2
6446 .na
6447 \fB\fB-a\fR\fR
6448 .ad
6449 .RS 6n
6450 Lists all of the current resource limits.
6451 .RE
6452 
6453 .sp
6454 .ne 2
6455 .na
6456 \fB\fB-c\fR\fR
6457 .ad
6458 .RS 6n
6459 The number of 512-byte blocks on the size of core dumps.
6460 .RE
6461 
6462 .sp
6463 .ne 2
6464 .na
6465 \fB\fB-d\fR\fR
6466 .ad
6467 .RS 6n
6468 The number of Kbytes on the size of the data area.
6469 .RE
6470 
6471 .sp
6472 .ne 2
6473 .na
6474 \fB\fB-f\fR\fR
6475 .ad
6476 .RS 6n
6477 The number of 512-byte blocks on files that can be written by the current
6478 process or by child processes (files of any size can be read).
6479 .RE
6480 
6481 .sp
6482 .ne 2
6483 .na
6484 \fB\fB-H\fR\fR
6485 .ad
6486 .RS 6n
6487 Specifies a hard limit for the specified resource.
6488 .sp
6489 A hard limit cannot be increased once it is set.
6490 .sp
6491 If neither the \fB-H\fR nor \fB-S\fR option is specified, the limit applies to
6492 both. The current resource limit is printed when \fIlimit\fR is omitted. In
6493 this case, the soft limit is printed unless \fB-H\fR is specified.
6494 .RE
6495 
6496 .sp
6497 .ne 2
6498 .na
6499 \fB\fB-m\fR\fR
6500 .ad
6501 .RS 6n
6502 The number of Kbytes on the size of physical memory.
6503 .RE
6504 
6505 .sp
6506 .ne 2
6507 .na
6508 \fB\fB-n\fR\fR
6509 .ad
6510 .RS 6n
6511 The number of file descriptors plus 1.
6512 .RE
6513 
6514 .sp
6515 .ne 2
6516 .na
6517 \fB\fB-p\fR\fR
6518 .ad
6519 .RS 6n
6520 The number of 512-byte blocks for pipe buffering.
6521 .RE
6522 
6523 .sp
6524 .ne 2
6525 .na
6526 \fB\fB-s\fR\fR
6527 .ad
6528 .RS 6n
6529 The number of Kbytes on the size of the stack area.
6530 .RE
6531 
6532 .sp
6533 .ne 2
6534 .na
6535 \fB\fB-S\fR\fR
6536 .ad
6537 .RS 6n
6538 Specifies a soft limit for the specified resource.
6539 .sp
6540 A soft limit can be increased up to the value of the hard limit.
6541 .sp
6542 If neither the \fB-H\fR nor \fB-S\fR option is specified, the limit applies to
6543 both. The current resource limit is printed when \fIlimit\fR is omitted. In
6544 this case, the soft limit is printed unless \fB-H\fR is specified.
6545 .RE
6546 
6547 .sp
6548 .ne 2
6549 .na
6550 \fB\fB-t\fR\fR
6551 .ad
6552 .RS 6n
6553 The number of CPU seconds to be used by each process.
6554 .RE
6555 
6556 .sp
6557 .ne 2
6558 .na
6559 \fB\fB-v\fR\fR
6560 .ad
6561 .RS 6n
6562 The number of Kbytes for virtual memory.
6563 .RE
6564 
6565 .RE
6566 
6567 .sp
6568 .ne 2
6569 .na
6570 \fB\fBumask\fR \fB[\fR\fB-S\fR\fB]\fR\fB[\fR\fImask\fR\fB]\fR\fR
6571 .ad
6572 .sp .6
6573 .RS 4n
6574 The user file-creation mask is set to \fImask\fR. \fImask\fR can either be an
6575 octal number or a symbolic value as described in \fBchmod\fR(1).
6576 .sp
6577 If a symbolic value is specified, the new \fBumask\fR value is the complement
6578 of the result of applying \fImask\fR to the complement of the previous
6579 \fBumask\fR value. If \fImask\fR is omitted, the current value of the mask is
6580 printed. The \fB-S\fR option causes the mode to be printed as a symbolic value.
6581 Otherwise, the mask is printed in octal.
6582 .sp
6583 See \fBumask\fR(2)
6584 .RE
6585 
6586 .sp
6587 .ne 2
6588 .na
6589 \fB\fB+unalias\fR \fB[\fR\fB-a\fR\fB]\fR \fIname\fR\fR
6590 .ad
6591 .sp .6
6592 .RS 4n
6593 The aliases specified by the list of \fIname\fRs are removed from the alias
6594 list. The \fB-a\fR option causes all the aliases to be unset.
6595 .RE
6596 
6597 .sp
6598 .ne 2
6599 .na
6600 \fB\fB+unset\fR \fB[\fR\fB-fnv\fR\fB]\fR \fIvname\fR\fR
6601 .ad
6602 .sp .6
6603 .RS 4n
6604 The variables specified by the list of \fIvname\fRs are unassigned, i.e., their
6605 values and attributes are erased. Read-only variables cannot be unset. If the
6606 \fB-f\fR option is set, then the names refer to function names. If the \fB-v\fR
6607 option is set, then the names refer to variable names. The \fB-f\fR option
6608 overrides \fB-v\fR. If \fB-n\fR is set and \fIname\fR is a name reference, then
6609 \fIname\fR is unset rather than the variable that it references. The default is
6610 equivalent to \fB-v\fR. Unsetting \fBLINENO\fR, \fBMAILCHECK\fR, \fBOPTARG\fR,
6611 \fBOPTIND\fR, \fBRANDOM\fR, \fBSECONDS\fR, \fBTMOUT\fR, and \fB_\fR removes
6612 their special meaning even if they are subsequently assigned to.
6613 .RE
6614 
6615 .sp
6616 .ne 2
6617 .na
6618 \fB\fBwait\fR \fB[\fR\fIjob\fR\fB]\fR\fR
6619 .ad
6620 .sp .6
6621 .RS 4n
6622 Wait for the specified job and report its termination status. If \fIjob\fR is
6623 not specified, then all currently active child processes are waited for. The
6624 exit status from this command is that of the last process waited for if
6625 \fIjob\fR is specified; otherwise it is zero. See \fBJobs\fR for a description
6626 of the format of \fIjob\fR.
6627 .RE
6628 
6629 .sp
6630 .ne 2
6631 .na
6632 \fB\fBwhence\fR \fB[\fR\fB-afpv\fR\fB]\fR \fIname ...\fR\fR
6633 .ad
6634 .sp .6
6635 .RS 4n
6636 For each \fIname\fR, indicate how it would be interpreted if used as a command
6637 name. The \fB-v\fR option produces a more verbose report. The \fB-f\fR option
6638 skips the search for functions. The \fB-p\fR option does a path search for
6639 \fIname\fR even if name is an alias, a function, or a reserved word. The
6640 \fB-a\fR option is similar to the -v option but causes all interpretations of
6641 the specified name to be reported.
6642 .RE
6643 
6644 .SS "Invocation"
6645 .sp
6646 .LP
6647 If the shell is invoked by \fBexec\fR(2), and the first character of argument
6648 zero (\fB$0\fR) is \fB-\fR, then the shell is assumed to be a login shell and
6649 commands are read from \fB/etc/profile\fR and then from either .\fBprofile\fR
6650 in the current directory or \fB$HOME/.profile\fR, if either file exists. Next,
6651 for interactive shells, commands are read first from \fB/etc/ksh.kshrc\fR, and
6652 then from the file named by performing parameter expansion, command
6653 substitution, and arithmetic substitution on the value of the environment
6654 variable \fBENV\fR if the file exists. If the \fB-s\fR option is not present
6655 and \fIarg\fR and a file by the name of \fIarg\fR exists, then it reads and
6656 executes this script. Otherwise, if the first \fIarg\fR does not contain a
6657 \fB/\fR, a path search is performed on the first \fIarg\fR to determine the
6658 name of the script to execute. The script \fIarg\fR must have execute
6659 permission and any \fBsetuid\fR and \fBsetgid\fR settings are ignored. If the
6660 script is not found on the path, \fIarg\fR is processed as if it named a
6661 built-in command or function.
6662 .sp
6663 .LP
6664 Commands are then read as described, and the following options are interpreted
6665 by the shell when it is invoked:
6666 .sp
6667 .ne 2
6668 .na
6669 \fB\fB-c\fR\fR
6670 .ad
6671 .RS 15n
6672 If the \fB-c\fR option is present, then commands are read from the first
6673 \fIarg\fR. Any remaining arguments become positional parameters starting at
6674 \fB0\fR.
6675 .RE
6676 
6677 .sp
6678 .ne 2
6679 .na
6680 \fB\fB-D\fR\fR
6681 .ad
6682 .RS 15n
6683 A list of all double quoted strings that are preceded by a \fB$\fR is printed
6684 on standard output and the shell exits. This set of strings is subject to
6685 language translation when the locale is not C or POSIX. No commands are
6686 executed.
6687 .RE
6688 
6689 .sp
6690 .ne 2
6691 .na
6692 \fB\fB-i\fR\fR
6693 .ad
6694 .RS 15n
6695 If the \fB-i\fR option is present or if the shell input and output are attached
6696 to a terminal (as told by \fBtcgetattr\fR(3C), this shell is interactive. In
6697 this case \fBTERM\fR is ignored (so that \fBkill 0\fR does not kill an
6698 interactive shell) and \fBINTR\fR is caught and ignored (so that wait is
6699 interruptible). In all cases, \fBQUIT\fR is ignored by the shell.
6700 .RE
6701 
6702 .sp
6703 .ne 2
6704 .na
6705 \fB\fB-R\fR \fIfilename\fR\fR
6706 .ad
6707 .RS 15n
6708 The \fB-R\fR \fIfilename\fR option is used to generate a cross reference
6709 database that can be used by a separate utility to find definitions and
6710 references for variables and commands.
6711 .RE
6712 
6713 .sp
6714 .ne 2
6715 .na
6716 \fB\fB-r\fR\fR
6717 .ad
6718 .RS 15n
6719 If the \fB-r\fR option is present, the shell is a restricted shell.
6720 .RE
6721 
6722 .sp
6723 .ne 2
6724 .na
6725 \fB\fB-s\fR\fR
6726 .ad
6727 .RS 15n
6728 If the \fB-s\fR option is present or if no arguments remain, then commands are
6729 read from the standard input. Shell output, except for the output of the
6730 \fBSpecial Commands\fR listed, is written to file descriptor 2.
6731 .RE
6732 
6733 .sp
6734 .LP
6735 The remaining options and arguments are described under the \fBset\fR command.
6736 An optional \fB-\fR as the first argument is ignored.
6737 .SS "\fBrksh93\fR Only"
6738 .sp
6739 .LP
6740 \fBrksh93\fR is used to set up login names and execution environments whose
6741 capabilities are more controlled than those of the standard shell.
6742 .sp
6743 .LP
6744 The actions of \fBrksh93\fR are identical to those of \fBksh93\fR, except that
6745 the following are disallowed:
6746 .RS +4
6747 .TP
6748 .ie t \(bu
6749 .el o
6750 Unsetting the restricted option
6751 .RE
6752 .RS +4
6753 .TP
6754 .ie t \(bu
6755 .el o
6756 Changing directory. See \fBcd\fR(1).
6757 .RE
6758 .RS +4
6759 .TP
6760 .ie t \(bu
6761 .el o
6762 Setting or unsetting the value or attributes of \fBSHELL\fR, \fBENV\fR,
6763 \fBFPATH\fR, or \fBPATH\fR
6764 .RE
6765 .RS +4
6766 .TP
6767 .ie t \(bu
6768 .el o
6769 Specifying path or command names containing \fB/\fR,
6770 .RE
6771 .RS +4
6772 .TP
6773 .ie t \(bu
6774 .el o
6775 Redirecting output (\fB>\fR, \fB>\fR\fB|\fR, \fB<>\fR, and \fB>>\fR).
6776 .RE
6777 .RS +4
6778 .TP
6779 .ie t \(bu
6780 .el o
6781 Adding or deleting built-in commands.
6782 .RE
6783 .RS +4
6784 .TP
6785 .ie t \(bu
6786 .el o
6787 Using \fBcommand\fR \fB-p\fR to invoke a command.
6788 .RE
6789 .sp
6790 .LP
6791 These restrictions are enforced after .\fBprofile\fR and the \fBENV\fR files
6792 are interpreted.
6793 .sp
6794 .LP
6795 When a command to be executed is found to be a shell procedure, \fBrksh93\fR
6796 invokes \fBksh93\fR to execute it. Thus, it is possible to provide to the
6797 end-user shell procedures that have access to the full power of the standard
6798 shell, while imposing a limited menu of commands. This scheme assumes that the
6799 end-user does not have write and execute permissions in the same directory. The
6800 net effect of these rules is that the writer of the .\fBprofile\fR has complete
6801 control over user actions, by performing guaranteed setup actions and leaving
6802 the user in an appropriate directory (probably not the login directory). The
6803 system administrator often sets up a directory of commands, for example,
6804 \fB/usr/rbin\fR, that can be safely invoked by \fBrksh\fR.
6805 .SH USAGE
6806 .sp
6807 .LP
6808 See \fBlargefile\fR(5) for the description of the behavior of \fBksh93\fR and
6809 \fBrksh93\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
6810 bytes).
6811 .SH EXIT STATUS
6812 .sp
6813 .LP
6814 The following exit values are returned:
6815 .sp
6816 .ne 2
6817 .na
6818 \fB\fBnon-zero\fR\fR
6819 .ad
6820 .sp .6
6821 .RS 4n
6822 Returns \fBnon-zero\fR when errors, such as syntax errors, are detected by the
6823 shell.
6824 .sp
6825 If the shell is being used non-interactively, then execution of the shell file
6826 is abandoned unless the error occurs inside a sub-shell in which case the
6827 sub-shell is abandoned.
6828 .RE
6829 
6830 .sp
6831 .ne 2
6832 .na
6833 \fB\fIexit status of last command executed\fR\fR
6834 .ad
6835 .sp .6
6836 .RS 4n
6837 Returns the exit status of the last command executed.
6838 .sp
6839 Run time errors detected by the shell are reported by printing the command or
6840 function name and the error condition. If the line number that the error
6841 occurred on is greater than one, then the line number is also printed in square
6842 brackets (\fB[]\fR) after the command or function name.
6843 .sp
6844 See the \fBksh93 exit\fR command for additional details.
6845 .RE
6846 
6847 .SH FILES
6848 .sp
6849 .ne 2
6850 .na
6851 \fB\fB/etc/profile\fR\fR
6852 .ad
6853 .sp .6
6854 .RS 4n
6855 The system initialization file, executed for login shells.
6856 .RE
6857 
6858 .sp
6859 .ne 2
6860 .na
6861 \fB\fB/etc/ksh.kshrc\fR\fR
6862 .ad
6863 .sp .6
6864 .RS 4n
6865 The system wide startup file, executed for interactive shells.
6866 .RE
6867 
6868 .sp
6869 .ne 2
6870 .na
6871 \fB\fB$HOME/.profile\fR\fR
6872 .ad
6873 .sp .6
6874 .RS 4n
6875 The personal initialization file, executed for login shells after
6876 \fB/etc/profile\fR.
6877 .RE
6878 
6879 .sp
6880 .ne 2
6881 .na
6882 \fB\fB$HOME/.kshrc\fR\fR
6883 .ad
6884 .sp .6
6885 .RS 4n
6886 Default personal initialization file, executed after \fB/etc/ksh.kshrc\fR, for
6887 interactive shells when \fBENV\fR is not set.
6888 .RE
6889 
6890 .sp
6891 .ne 2
6892 .na
6893 \fB\fB/etc/suid-profile\fR\fR
6894 .ad
6895 .sp .6
6896 .RS 4n
6897 Alternative initialization file, executed instead of the personal
6898 initialization file when the real and effective user or group id do not match.
6899 .RE
6900 
6901 .sp
6902 .ne 2
6903 .na
6904 \fB\fB/dev/null\fR\fR
6905 .ad
6906 .sp .6
6907 .RS 4n
6908 NULL device.
6909 .RE
6910 
6911 .SH AUTHORS
6912 .sp
6913 .LP
6914 David Korn, \fBdgk@research.att.com\fR
6915 .SH ATTRIBUTES
6916 .sp
6917 .LP
6918 See \fBattributes\fR(5) for descriptions of the following attributes:
6919 .sp
6920 
6921 .sp
6922 .TS
6923 box;
6924 c | c
6925 l | l .
6926 ATTRIBUTE TYPE  ATTRIBUTE VALUE
6927 _
6928 Interface Stability     See below.
6929 .TE
6930 
6931 .sp
6932 .LP
6933 The scripting interface is Uncommitted. The environment variables,
6934 \fB\&.paths\fR feature, and editing modes are Volatile.
6935 .SH SEE ALSO
6936 .sp
6937 .LP
6938 \fBcat\fR(1), \fBcd\fR(1), \fBchmod\fR(1), \fBcut\fR(1), \fBdate\fR(1),
6939 \fBegrep\fR(1), \fBecho\fR(1), \fBegrep\fR(1), \fBenv\fR(1), \fBfgrep\fR(1),
6940 \fBgrep\fR(1), \fBlogin\fR(1), \fBnewgrp\fR(1), \fBpaste\fR(1),
6941 \fBprintf\fR(1), \fBstty\fR(1), \fBtest\fR(1), \fBumask\fR(1), \fBvi\fR(1),
6942 \fBdup\fR(2), \fBexec\fR(2), \fBfork\fR(2), \fBioctl\fR(2), \fBlseek\fR(2),
6943 \fBpathconf\fR(2), \fBpipe\fR(2), \fBsysconf\fR(3C), \fBulimit\fR(2),
6944 \fBumask\fR(2), \fBrand\fR(3C)\fBtcgetattr\fR(3C), \fBwait\fR(3C),
6945 \fBa.out\fR(4), \fBprofile\fR(4), \fBattributes\fR(5), \fBenviron\fR(5),
6946 \fBlargefile\fR(5), \fBstandards\fR(5)
6947 .sp
6948 .LP
6949 Bolsky, Morris I. and Korn, David G., \fIThe New KornShell Command and
6950 Programming Language\fR, Prentice Hall, 1995.
6951 .sp
6952 .LP
6953 \fIPOSIX-Part 2: Shell and Utilities, IEEE Std 1003.2-1992, ISO/IEC 9945-2\fR,
6954 IEEE, 1993.
6955 .SH NOTES
6956 .sp
6957 .LP
6958 \fBksh93\fR scripts should choose shell function names outside the namespace
6959 used by reserved keywords of the ISO C99, C++ and JAVA languages to avoid
6960 collisions with future enhancements to \fBksh93\fR.
6961 .sp
6962 .LP
6963 If a command is executed, and then a command with the same name is installed in
6964 a directory in the search path before the directory where the original command
6965 was found, the shell continues to \fBexec\fR the original command. Use the
6966 \fB-t\fR option of the alias command to correct this situation.
6967 .sp
6968 .LP
6969 Some very old shell scripts contain a caret (\fB^\fR) as a synonym for the pipe
6970 character (\fB|\fR).
6971 .sp
6972 .LP
6973 Using the \fBhist\fR built-in command within a compound command causes the
6974 whole command to disappear from the history file.
6975 .sp
6976 .LP
6977 The built-in command \fB\&.\fR \fIfile\fR reads the whole file before any
6978 commands are executed. \fBalias\fR and \fBunalias\fR commands in the file do
6979 not apply to any commands defined in the file.
6980 .sp
6981 .LP
6982 Traps are not processed while a job is waiting for a foreground process. Thus,
6983 a trap on \fBCHLD\fR is not executed until the foreground job terminates.
6984 .sp
6985 .LP
6986 It is a good idea to leave a space after the comma operator in arithmetic
6987 expressions to prevent the comma from being interpreted as the decimal point
6988 character in certain locales.
6989 .sp
6990 .LP
6991 There might be some restrictions on creating a \fB\&.paths\fR file which is
6992 portable across other operating systems.
6993 .sp
6994 .LP
6995 If the system supports the 64-bit instruction set, \fB/bin/ksh93\fR executes
6996 the 64-bit version of \fBksh93\fR.