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