1DASH(1)                   BSD General Commands Manual                  DASH(1)
2

NAME

4     dash — command interpreter (shell)
5

SYNOPSIS

7     dash [-aCefnuvxIimqVEb] [+aCefnuvxIimqVEb] [-o option_name]
8          [+o option_name] [command_file [argument ...]]
9     dash -c [-aCefnuvxIimqVEb] [+aCefnuvxIimqVEb] [-o option_name]
10          [+o option_name] command_string [command_name [argument ...]]
11     dash -s [-aCefnuvxIimqVEb] [+aCefnuvxIimqVEb] [-o option_name]
12          [+o option_name] [argument ...]
13

DESCRIPTION

15     dash is the standard command interpreter for the system.  The current
16     version of dash is in the process of being changed to conform with the
17     POSIX 1003.2 and 1003.2a specifications for the shell.  This version has
18     many features which make it appear similar in some respects to the Korn
19     shell, but it is not a Korn shell clone (see ksh(1)).  Only features des‐
20     ignated by POSIX, plus a few Berkeley extensions, are being incorporated
21     into this shell.  This man page is not intended to be a tutorial or a
22     complete specification of the shell.
23
24   Overview
25     The shell is a command that reads lines from either a file or the termi‐
26     nal, interprets them, and generally executes other commands.  It is the
27     program that is running when a user logs into the system (although a user
28     can select a different shell with the chsh(1) command).  The shell imple‐
29     ments a language that has flow control constructs, a macro facility that
30     provides a variety of features in addition to data storage, along with
31     built in history and line editing capabilities.  It incorporates many
32     features to aid interactive use and has the advantage that the interpre‐
33     tative language is common to both interactive and non-interactive use
34     (shell scripts).  That is, commands can be typed directly to the running
35     shell or can be put into a file and the file can be executed directly by
36     the shell.
37
38   Invocation
39     If no args are present and if the standard input of the shell is con‐
40     nected to a terminal (or if the -i flag is set), and the -c option is not
41     present, the shell is considered an interactive shell.  An interactive
42     shell generally prompts before each command and handles programming and
43     command errors differently (as described below).  When first starting,
44     the shell inspects argument 0, and if it begins with a dash ‘-’, the
45     shell is also considered a login shell.  This is normally done automati‐
46     cally by the system when the user first logs in.  A login shell first
47     reads commands from the files /etc/profile and .profile if they exist.
48     If the environment variable ENV is set on entry to an interactive shell,
49     or is set in the .profile of a login shell, the shell next reads commands
50     from the file named in ENV.  Therefore, a user should place commands that
51     are to be executed only at login time in the .profile file, and commands
52     that are executed for every interactive shell inside the ENV file.  To
53     set the ENV variable to some file, place the following line in your
54     .profile of your home directory
55
56           ENV=$HOME/.shinit; export ENV
57
58     substituting for “.shinit” any filename you wish.
59
60     If command line arguments besides the options have been specified, then
61     the shell treats the first argument as the name of a file from which to
62     read commands (a shell script), and the remaining arguments are set as
63     the positional parameters of the shell ($1, $2, etc).  Otherwise, the
64     shell reads commands from its standard input.
65
66   Argument List Processing
67     All of the single letter options that have a corresponding name can be
68     used as an argument to the -o option.  The set -o name is provided next
69     to the single letter option in the description below.  Specifying a dash
70     “-” turns the option on, while using a plus “+” disables the option.  The
71     following options can be set from the command line or with the set
72     builtin (described later).
73
74           -a allexport     Export all variables assigned to.
75
76           -c               Read commands from the command_string operand
77                            instead of from the standard input.  Special
78                            parameter 0 will be set from the command_name op‐
79                            erand and the positional parameters ($1, $2, etc.)
80                            set from the remaining argument operands.
81
82           -C noclobber     Don't overwrite existing files with “>”.
83
84           -e errexit       If not interactive, exit immediately if any
85                            untested command fails.  The exit status of a com‐
86                            mand is considered to be explicitly tested if the
87                            command is used to control an if, elif, while, or
88                            until; or if the command is the left hand operand
89                            of an “&&” or “||” operator.
90
91           -f noglob        Disable pathname expansion.
92
93           -n noexec        If not interactive, read commands but do not exe‐
94                            cute them.  This is useful for checking the syntax
95                            of shell scripts.
96
97           -u nounset       Write a message to standard error when attempting
98                            to expand a variable that is not set, and if the
99                            shell is not interactive, exit immediately.
100
101           -v verbose       The shell writes its input to standard error as it
102                            is read.  Useful for debugging.
103
104           -x xtrace        Write each command to standard error (preceded by
105                            a ‘+ ’) before it is executed.  Useful for debug‐
106                            ging.
107
108           -I ignoreeof     Ignore EOF's from input when interactive.
109
110           -i interactive   Force the shell to behave interactively.
111
112           -l               Make dash act as if it had been invoked as a login
113                            shell.
114
115           -m monitor       Turn on job control (set automatically when inter‐
116                            active).
117
118           -s stdin         Read commands from standard input (set automati‐
119                            cally if no file arguments are present).  This
120                            option has no effect when set after the shell has
121                            already started running (i.e. with set).
122
123           -V vi            Enable the built-in vi(1) command line editor
124                            (disables -E if it has been set).
125
126           -E emacs         Enable the built-in emacs(1) command line editor
127                            (disables -V if it has been set).
128
129           -b notify        Enable asynchronous notification of background job
130                            completion.  (UNIMPLEMENTED for 4.4alpha)
131
132   Lexical Structure
133     The shell reads input in terms of lines from a file and breaks it up into
134     words at whitespace (blanks and tabs), and at certain sequences of char‐
135     acters that are special to the shell called “operators”.  There are two
136     types of operators: control operators and redirection operators (their
137     meaning is discussed later).  Following is a list of operators:
138
139           Control operators:
140                 & && ( ) ; ;; | || <newline>
141
142           Redirection operators:
143                 < > >| << >> <& >& <<- <>
144
145   Quoting
146     Quoting is used to remove the special meaning of certain characters or
147     words to the shell, such as operators, whitespace, or keywords.  There
148     are three types of quoting: matched single quotes, matched double quotes,
149     and backslash.
150
151   Backslash
152     A backslash preserves the literal meaning of the following character,
153     with the exception of ⟨newline⟩.  A backslash preceding a ⟨newline⟩ is
154     treated as a line continuation.
155
156   Single Quotes
157     Enclosing characters in single quotes preserves the literal meaning of
158     all the characters (except single quotes, making it impossible to put
159     single-quotes in a single-quoted string).
160
161   Double Quotes
162     Enclosing characters within double quotes preserves the literal meaning
163     of all characters except dollarsign ($), backquote (`), and backslash
164     (\).  The backslash inside double quotes is historically weird, and
165     serves to quote only the following characters:
166           $ ` " \ <newline>.
167     Otherwise it remains literal.
168
169   Reserved Words
170     Reserved words are words that have special meaning to the shell and are
171     recognized at the beginning of a line and after a control operator.  The
172     following are reserved words:
173
174           !       elif    fi      while   case
175           else    for     then    {       }
176           do      done    until   if      esac
177
178     Their meaning is discussed later.
179
180   Aliases
181     An alias is a name and corresponding value set using the alias(1) builtin
182     command.  Whenever a reserved word may occur (see above), and after
183     checking for reserved words, the shell checks the word to see if it
184     matches an alias.  If it does, it replaces it in the input stream with
185     its value.  For example, if there is an alias called “lf” with the value
186     “ls -F”, then the input:
187
188           lf foobar ⟨return⟩
189
190     would become
191
192           ls -F foobar ⟨return⟩
193
194     Aliases provide a convenient way for naive users to create shorthands for
195     commands without having to learn how to create functions with arguments.
196     They can also be used to create lexically obscure code.  This use is dis‐
197     couraged.
198
199   Commands
200     The shell interprets the words it reads according to a language, the
201     specification of which is outside the scope of this man page (refer to
202     the BNF in the POSIX 1003.2 document).  Essentially though, a line is
203     read and if the first word of the line (or after a control operator) is
204     not a reserved word, then the shell has recognized a simple command.
205     Otherwise, a complex command or some other special construct may have
206     been recognized.
207
208   Simple Commands
209     If a simple command has been recognized, the shell performs the following
210     actions:
211
212           1.   Leading words of the form “name=value” are stripped off and
213                assigned to the environment of the simple command.  Redirect‐
214                ion operators and their arguments (as described below) are
215                stripped off and saved for processing.
216
217           2.   The remaining words are expanded as described in the section
218                called “Expansions”, and the first remaining word is consid‐
219                ered the command name and the command is located.  The remain‐
220                ing words are considered the arguments of the command.  If no
221                command name resulted, then the “name=value” variable assign‐
222                ments recognized in item 1 affect the current shell.
223
224           3.   Redirections are performed as described in the next section.
225
226   Redirections
227     Redirections are used to change where a command reads its input or sends
228     its output.  In general, redirections open, close, or duplicate an exist‐
229     ing reference to a file.  The overall format used for redirection is:
230
231           [n] redir-op file
232
233     where redir-op is one of the redirection operators mentioned previously.
234     Following is a list of the possible redirections.  The [n] is an optional
235     number, as in ‘3’ (not ‘[3]’), that refers to a file descriptor.
236
237           [n]> file   Redirect standard output (or n) to file.
238
239           [n]>| file  Same, but override the -C option.
240
241           [n]>> file  Append standard output (or n) to file.
242
243           [n]< file   Redirect standard input (or n) from file.
244
245           [n1]<&n2    Duplicate standard input (or n1) from file descriptor
246                       n2.
247
248           [n]<&-      Close standard input (or n).
249
250           [n1]>&n2    Duplicate standard output (or n1) to n2.
251
252           [n]>&-      Close standard output (or n).
253
254           [n]<> file  Open file for reading and writing on standard input (or
255                       n).
256
257     The following redirection is often called a “here-document”.
258
259           [n]<< delimiter
260                 here-doc-text ...
261           delimiter
262
263     All the text on successive lines up to the delimiter is saved away and
264     made available to the command on standard input, or file descriptor n if
265     it is specified.  If the delimiter as specified on the initial line is
266     quoted, then the here-doc-text is treated literally, otherwise the text
267     is subjected to parameter expansion, command substitution, and arithmetic
268     expansion (as described in the section on “Expansions”).  If the operator
269     is “<<-” instead of “<<”, then leading tabs in the here-doc-text are
270     stripped.
271
272   Search and Execution
273     There are three types of commands: shell functions, builtin commands, and
274     normal programs -- and the command is searched for (by name) in that
275     order.  They each are executed in a different way.
276
277     When a shell function is executed, all of the shell positional parameters
278     (except $0, which remains unchanged) are set to the arguments of the
279     shell function.  The variables which are explicitly placed in the envi‐
280     ronment of the command (by placing assignments to them before the func‐
281     tion name) are made local to the function and are set to the values
282     given.  Then the command given in the function definition is executed.
283     The positional parameters are restored to their original values when the
284     command completes.  This all occurs within the current shell.
285
286     Shell builtins are executed internally to the shell, without spawning a
287     new process.
288
289     Otherwise, if the command name doesn't match a function or builtin, the
290     command is searched for as a normal program in the file system (as
291     described in the next section).  When a normal program is executed, the
292     shell runs the program, passing the arguments and the environment to the
293     program.  If the program is not a normal executable file (i.e., if it
294     does not begin with the "magic number" whose ASCII representation is
295     "#!", so execve(2) returns ENOEXEC then) the shell will interpret the
296     program in a subshell.  The child shell will reinitialize itself in this
297     case, so that the effect will be as if a new shell had been invoked to
298     handle the ad-hoc shell script, except that the location of hashed com‐
299     mands located in the parent shell will be remembered by the child.
300
301     Note that previous versions of this document and the source code itself
302     misleadingly and sporadically refer to a shell script without a magic
303     number as a "shell procedure".
304
305   Path Search
306     When locating a command, the shell first looks to see if it has a shell
307     function by that name.  Then it looks for a builtin command by that name.
308     If a builtin command is not found, one of two things happen:
309
310     1.   Command names containing a slash are simply executed without per‐
311          forming any searches.
312
313     2.   The shell searches each entry in PATH in turn for the command.  The
314          value of the PATH variable should be a series of entries separated
315          by colons.  Each entry consists of a directory name.  The current
316          directory may be indicated implicitly by an empty directory name, or
317          explicitly by a single period.
318
319   Command Exit Status
320     Each command has an exit status that can influence the behaviour of other
321     shell commands.  The paradigm is that a command exits with zero for nor‐
322     mal or success, and non-zero for failure, error, or a false indication.
323     The man page for each command should indicate the various exit codes and
324     what they mean.  Additionally, the builtin commands return exit codes, as
325     does an executed shell function.
326
327     If a command consists entirely of variable assignments then the exit sta‐
328     tus of the command is that of the last command substitution if any, oth‐
329     erwise 0.
330
331   Complex Commands
332     Complex commands are combinations of simple commands with control opera‐
333     tors or reserved words, together creating a larger complex command.  More
334     generally, a command is one of the following:
335
336     ·   simple command
337
338     ·   pipeline
339
340     ·   list or compound-list
341
342     ·   compound command
343
344     ·   function definition
345
346     Unless otherwise stated, the exit status of a command is that of the last
347     simple command executed by the command.
348
349   Pipelines
350     A pipeline is a sequence of one or more commands separated by the control
351     operator |.  The standard output of all but the last command is connected
352     to the standard input of the next command.  The standard output of the
353     last command is inherited from the shell, as usual.
354
355     The format for a pipeline is:
356
357           [!] command1 [| command2 ...]
358
359     The standard output of command1 is connected to the standard input of
360     command2.  The standard input, standard output, or both of a command is
361     considered to be assigned by the pipeline before any redirection speci‐
362     fied by redirection operators that are part of the command.
363
364     If the pipeline is not in the background (discussed later), the shell
365     waits for all commands to complete.
366
367     If the reserved word ! does not precede the pipeline, the exit status is
368     the exit status of the last command specified in the pipeline.  Other‐
369     wise, the exit status is the logical NOT of the exit status of the last
370     command.  That is, if the last command returns zero, the exit status is
371     1; if the last command returns greater than zero, the exit status is
372     zero.
373
374     Because pipeline assignment of standard input or standard output or both
375     takes place before redirection, it can be modified by redirection.  For
376     example:
377
378           $ command1 2>&1 | command2
379
380     sends both the standard output and standard error of command1 to the
381     standard input of command2.
382
383     A ; or ⟨newline⟩ terminator causes the preceding AND-OR-list (described
384     next) to be executed sequentially; a & causes asynchronous execution of
385     the preceding AND-OR-list.
386
387     Note that unlike some other shells, each process in the pipeline is a
388     child of the invoking shell (unless it is a shell builtin, in which case
389     it executes in the current shell -- but any effect it has on the environ‐
390     ment is wiped).
391
392   Background Commands -- &
393     If a command is terminated by the control operator ampersand (&), the
394     shell executes the command asynchronously -- that is, the shell does not
395     wait for the command to finish before executing the next command.
396
397     The format for running a command in background is:
398
399           command1 & [command2 & ...]
400
401     If the shell is not interactive, the standard input of an asynchronous
402     command is set to /dev/null.
403
404   Lists -- Generally Speaking
405     A list is a sequence of zero or more commands separated by newlines,
406     semicolons, or ampersands, and optionally terminated by one of these
407     three characters.  The commands in a list are executed in the order they
408     are written.  If command is followed by an ampersand, the shell starts
409     the command and immediately proceed onto the next command; otherwise it
410     waits for the command to terminate before proceeding to the next one.
411
412   Short-Circuit List Operators
413     “&&” and “||” are AND-OR list operators.  “&&” executes the first com‐
414     mand, and then executes the second command iff the exit status of the
415     first command is zero.  “||” is similar, but executes the second command
416     iff the exit status of the first command is nonzero.  “&&” and “||” both
417     have the same priority.
418
419   Flow-Control Constructs -- if, while, for, case
420     The syntax of the if command is
421
422           if list
423           then list
424           [ elif list
425           then    list ] ...
426           [ else list ]
427           fi
428
429     The syntax of the while command is
430
431           while list
432           do   list
433           done
434
435     The two lists are executed repeatedly while the exit status of the first
436     list is zero.  The until command is similar, but has the word until in
437     place of while, which causes it to repeat until the exit status of the
438     first list is zero.
439
440     The syntax of the for command is
441
442           for variable [ in [ word ... ] ]
443           do   list
444           done
445
446     The words following in are expanded, and then the list is executed
447     repeatedly with the variable set to each word in turn.  Omitting in word
448     ... is equivalent to in "$@".
449
450     The syntax of the break and continue command is
451
452           break [ num ]
453           continue [ num ]
454
455     Break terminates the num innermost for or while loops.  Continue contin‐
456     ues with the next iteration of the innermost loop.  These are implemented
457     as builtin commands.
458
459     The syntax of the case command is
460
461           case word in
462           pattern) list ;;
463           ...
464           esac
465
466     The pattern can actually be one or more patterns (see Shell Patterns
467     described later), separated by “|” characters.
468
469   Grouping Commands Together
470     Commands may be grouped by writing either
471
472           (list)
473
474     or
475
476           { list; }
477
478     The first of these executes the commands in a subshell.  Builtin commands
479     grouped into a (list) will not affect the current shell.  The second form
480     does not fork another shell so is slightly more efficient.  Grouping com‐
481     mands together this way allows you to redirect their output as though
482     they were one program:
483
484           { printf " hello " ; printf " world\n" ; } > greeting
485
486     Note that “}” must follow a control operator (here, “;”) so that it is
487     recognized as a reserved word and not as another command argument.
488
489   Functions
490     The syntax of a function definition is
491
492           name () command
493
494     A function definition is an executable statement; when executed it
495     installs a function named name and returns an exit status of zero.  The
496     command is normally a list enclosed between “{” and “}”.
497
498     Variables may be declared to be local to a function by using a local com‐
499     mand.  This should appear as the first statement of a function, and the
500     syntax is
501
502           local [variable | -] ...
503
504     Local is implemented as a builtin command.
505
506     When a variable is made local, it inherits the initial value and exported
507     and readonly flags from the variable with the same name in the surround‐
508     ing scope, if there is one.  Otherwise, the variable is initially unset.
509     The shell uses dynamic scoping, so that if you make the variable x local
510     to function f, which then calls function g, references to the variable x
511     made inside g will refer to the variable x declared inside f, not to the
512     global variable named x.
513
514     The only special parameter that can be made local is “-”.  Making “-”
515     local any shell options that are changed via the set command inside the
516     function to be restored to their original values when the function
517     returns.
518
519     The syntax of the return command is
520
521           return [exitstatus]
522
523     It terminates the currently executing function.  Return is implemented as
524     a builtin command.
525
526   Variables and Parameters
527     The shell maintains a set of parameters.  A parameter denoted by a name
528     is called a variable.  When starting up, the shell turns all the environ‐
529     ment variables into shell variables.  New variables can be set using the
530     form
531
532           name=value
533
534     Variables set by the user must have a name consisting solely of alphabet‐
535     ics, numerics, and underscores - the first of which must not be numeric.
536     A parameter can also be denoted by a number or a special character as
537     explained below.
538
539   Positional Parameters
540     A positional parameter is a parameter denoted by a number (n > 0).  The
541     shell sets these initially to the values of its command line arguments
542     that follow the name of the shell script.  The set builtin can also be
543     used to set or reset them.
544
545   Special Parameters
546     A special parameter is a parameter denoted by one of the following spe‐
547     cial characters.  The value of the parameter is listed next to its char‐
548     acter.
549
550     *            Expands to the positional parameters, starting from one.
551                  When the expansion occurs within a double-quoted string it
552                  expands to a single field with the value of each parameter
553                  separated by the first character of the IFS variable, or by
554                  a ⟨space⟩ if IFS is unset.
555
556     @            Expands to the positional parameters, starting from one.
557                  When the expansion occurs within double-quotes, each posi‐
558                  tional parameter expands as a separate argument.  If there
559                  are no positional parameters, the expansion of @ generates
560                  zero arguments, even when @ is double-quoted.  What this
561                  basically means, for example, is if $1 is “abc” and $2 is
562                  “def ghi”, then "$@" expands to the two arguments:
563
564                        "abc" "def ghi"
565
566     #            Expands to the number of positional parameters.
567
568     ?            Expands to the exit status of the most recent pipeline.
569
570     - (Hyphen.)  Expands to the current option flags (the single-letter
571                  option names concatenated into a string) as specified on
572                  invocation, by the set builtin command, or implicitly by the
573                  shell.
574
575     $            Expands to the process ID of the invoked shell.  A subshell
576                  retains the same value of $ as its parent.
577
578     !            Expands to the process ID of the most recent background com‐
579                  mand executed from the current shell.  For a pipeline, the
580                  process ID is that of the last command in the pipeline.
581
582     0 (Zero.)    Expands to the name of the shell or shell script.
583
584   Word Expansions
585     This clause describes the various expansions that are performed on words.
586     Not all expansions are performed on every word, as explained later.
587
588     Tilde expansions, parameter expansions, command substitutions, arithmetic
589     expansions, and quote removals that occur within a single word expand to
590     a single field.  It is only field splitting or pathname expansion that
591     can create multiple fields from a single word.  The single exception to
592     this rule is the expansion of the special parameter @ within double-
593     quotes, as was described above.
594
595     The order of word expansion is:
596
597     1.   Tilde Expansion, Parameter Expansion, Command Substitution, Arith‐
598          metic Expansion (these all occur at the same time).
599
600     2.   Field Splitting is performed on fields generated by step (1) unless
601          the IFS variable is null.
602
603     3.   Pathname Expansion (unless set -f is in effect).
604
605     4.   Quote Removal.
606
607     The $ character is used to introduce parameter expansion, command substi‐
608     tution, or arithmetic evaluation.
609
610   Tilde Expansion (substituting a user's home directory)
611     A word beginning with an unquoted tilde character (~) is subjected to
612     tilde expansion.  All the characters up to a slash (/) or the end of the
613     word are treated as a username and are replaced with the user's home
614     directory.  If the username is missing (as in ~/foobar), the tilde is
615     replaced with the value of the HOME variable (the current user's home
616     directory).
617
618   Parameter Expansion
619     The format for parameter expansion is as follows:
620
621           ${expression}
622
623     where expression consists of all characters until the matching “}”.  Any
624     “}” escaped by a backslash or within a quoted string, and characters in
625     embedded arithmetic expansions, command substitutions, and variable
626     expansions, are not examined in determining the matching “}”.
627
628     The simplest form for parameter expansion is:
629
630           ${parameter}
631
632     The value, if any, of parameter is substituted.
633
634     The parameter name or symbol can be enclosed in braces, which are
635     optional except for positional parameters with more than one digit or
636     when parameter is followed by a character that could be interpreted as
637     part of the name.  If a parameter expansion occurs inside double-quotes:
638
639     1.   Pathname expansion is not performed on the results of the expansion.
640
641     2.   Field splitting is not performed on the results of the expansion,
642          with the exception of @.
643
644     In addition, a parameter expansion can be modified by using one of the
645     following formats.
646
647     ${parameter:-word}    Use Default Values.  If parameter is unset or null,
648                           the expansion of word is substituted; otherwise,
649                           the value of parameter is substituted.
650
651     ${parameter:=word}    Assign Default Values.  If parameter is unset or
652                           null, the expansion of word is assigned to parame‐
653                           ter.  In all cases, the final value of parameter is
654                           substituted.  Only variables, not positional param‐
655                           eters or special parameters, can be assigned in
656                           this way.
657
658     ${parameter:?[word]}  Indicate Error if Null or Unset.  If parameter is
659                           unset or null, the expansion of word (or a message
660                           indicating it is unset if word is omitted) is writ‐
661                           ten to standard error and the shell exits with a
662                           nonzero exit status.  Otherwise, the value of
663                           parameter is substituted.  An interactive shell
664                           need not exit.
665
666     ${parameter:+word}    Use Alternative Value.  If parameter is unset or
667                           null, null is substituted; otherwise, the expansion
668                           of word is substituted.
669
670     In the parameter expansions shown previously, use of the colon in the
671     format results in a test for a parameter that is unset or null; omission
672     of the colon results in a test for a parameter that is only unset.
673
674     ${#parameter}         String Length.  The length in characters of the
675                           value of parameter.
676
677     The following four varieties of parameter expansion provide for substring
678     processing.  In each case, pattern matching notation (see Shell
679     Patterns), rather than regular expression notation, is used to evaluate
680     the patterns.  If parameter is * or @, the result of the expansion is
681     unspecified.  Enclosing the full parameter expansion string in double-
682     quotes does not cause the following four varieties of pattern characters
683     to be quoted, whereas quoting characters within the braces has this
684     effect.
685
686     ${parameter%word}     Remove Smallest Suffix Pattern.  The word is
687                           expanded to produce a pattern.  The parameter
688                           expansion then results in parameter, with the
689                           smallest portion of the suffix matched by the pat‐
690                           tern deleted.
691
692     ${parameter%%word}    Remove Largest Suffix Pattern.  The word is
693                           expanded to produce a pattern.  The parameter
694                           expansion then results in parameter, with the
695                           largest portion of the suffix matched by the pat‐
696                           tern deleted.
697
698     ${parameter#word}     Remove Smallest Prefix Pattern.  The word is
699                           expanded to produce a pattern.  The parameter
700                           expansion then results in parameter, with the
701                           smallest portion of the prefix matched by the pat‐
702                           tern deleted.
703
704     ${parameter##word}    Remove Largest Prefix Pattern.  The word is
705                           expanded to produce a pattern.  The parameter
706                           expansion then results in parameter, with the
707                           largest portion of the prefix matched by the pat‐
708                           tern deleted.
709
710   Command Substitution
711     Command substitution allows the output of a command to be substituted in
712     place of the command name itself.  Command substitution occurs when the
713     command is enclosed as follows:
714
715           $(command)
716
717     or (“backquoted” version):
718
719           `command`
720
721     The shell expands the command substitution by executing command in a sub‐
722     shell environment and replacing the command substitution with the stan‐
723     dard output of the command, removing sequences of one or more ⟨newline⟩s
724     at the end of the substitution.  (Embedded ⟨newline⟩s before the end of
725     the output are not removed; however, during field splitting, they may be
726     translated into ⟨space⟩s, depending on the value of IFS and quoting that
727     is in effect.)
728
729   Arithmetic Expansion
730     Arithmetic expansion provides a mechanism for evaluating an arithmetic
731     expression and substituting its value.  The format for arithmetic expan‐
732     sion is as follows:
733
734           $((expression))
735
736     The expression is treated as if it were in double-quotes, except that a
737     double-quote inside the expression is not treated specially.  The shell
738     expands all tokens in the expression for parameter expansion, command
739     substitution, and quote removal.
740
741     Next, the shell treats this as an arithmetic expression and substitutes
742     the value of the expression.
743
744   White Space Splitting (Field Splitting)
745     After parameter expansion, command substitution, and arithmetic expansion
746     the shell scans the results of expansions and substitutions that did not
747     occur in double-quotes for field splitting and multiple fields can
748     result.
749
750     The shell treats each character of the IFS as a delimiter and uses the
751     delimiters to split the results of parameter expansion and command sub‐
752     stitution into fields.
753
754   Pathname Expansion (File Name Generation)
755     Unless the -f flag is set, file name generation is performed after word
756     splitting is complete.  Each word is viewed as a series of patterns, sep‐
757     arated by slashes.  The process of expansion replaces the word with the
758     names of all existing files whose names can be formed by replacing each
759     pattern with a string that matches the specified pattern.  There are two
760     restrictions on this: first, a pattern cannot match a string containing a
761     slash, and second, a pattern cannot match a string starting with a period
762     unless the first character of the pattern is a period.  The next section
763     describes the patterns used for both Pathname Expansion and the case com‐
764     mand.
765
766   Shell Patterns
767     A pattern consists of normal characters, which match themselves, and
768     meta-characters.  The meta-characters are “!”, “*”, “?”, and “[”.  These
769     characters lose their special meanings if they are quoted.  When command
770     or variable substitution is performed and the dollar sign or back quotes
771     are not double quoted, the value of the variable or the output of the
772     command is scanned for these characters and they are turned into meta-
773     characters.
774
775     An asterisk (“*”) matches any string of characters.  A question mark
776     matches any single character.  A left bracket (“[”) introduces a charac‐
777     ter class.  The end of the character class is indicated by a (“]”); if
778     the “]” is missing then the “[” matches a “[” rather than introducing a
779     character class.  A character class matches any of the characters between
780     the square brackets.  A range of characters may be specified using a
781     minus sign.  The character class may be complemented by making an excla‐
782     mation point the first character of the character class.
783
784     To include a “]” in a character class, make it the first character listed
785     (after the “!”, if any).  To include a minus sign, make it the first or
786     last character listed.
787
788   Builtins
789     This section lists the builtin commands which are builtin because they
790     need to perform some operation that can't be performed by a separate
791     process.  In addition to these, there are several other commands that may
792     be builtin for efficiency (e.g.  printf(1), echo(1), test(1), etc).
793
794     :
795
796     true   A null command that returns a 0 (true) exit value.
797
798     . file
799            The commands in the specified file are read and executed by the
800            shell.
801
802     alias [name[=string ...]]
803            If name=string is specified, the shell defines the alias name with
804            value string.  If just name is specified, the value of the alias
805            name is printed.  With no arguments, the alias builtin prints the
806            names and values of all defined aliases (see unalias).
807
808     bg [job] ...
809            Continue the specified jobs (or the current job if no jobs are
810            given) in the background.
811
812     command [-p] [-v] [-V] command [arg ...]
813            Execute the specified command but ignore shell functions when
814            searching for it.  (This is useful when you have a shell function
815            with the same name as a builtin command.)
816
817            -p     search for command using a PATH that guarantees to find all
818                   the standard utilities.
819
820            -V     Do not execute the command but search for the command and
821                   print the resolution of the command search.  This is the
822                   same as the type builtin.
823
824            -v     Do not execute the command but search for the command and
825                   print the absolute pathname of utilities, the name for
826                   builtins or the expansion of aliases.
827
828     cd -
829
830     cd [-LP] [directory]
831            Switch to the specified directory (default HOME).  If an entry for
832            CDPATH appears in the environment of the cd command or the shell
833            variable CDPATH is set and the directory name does not begin with
834            a slash, then the directories listed in CDPATH will be searched
835            for the specified directory.  The format of CDPATH is the same as
836            that of PATH.  If a single dash is specified as the argument, it
837            will be replaced by the value of OLDPWD.  The cd command will
838            print out the name of the directory that it actually switched to
839            if this is different from the name that the user gave.  These may
840            be different either because the CDPATH mechanism was used or
841            because the argument is a single dash.  The -P option causes the
842            physical directory structure to be used, that is, all symbolic
843            links are resolved to their respective values.  The -L option
844            turns off the effect of any preceding -P options.
845
846     echo [-n] args...
847            Print the arguments on the standard output, separated by spaces.
848            Unless the -n option is present, a newline is output following the
849            arguments.
850
851            If any of the following sequences of characters is encountered
852            during output, the sequence is not output.  Instead, the specified
853            action is performed:
854
855            \b      A backspace character is output.
856
857            \c      Subsequent output is suppressed.  This is normally used at
858                    the end of the last argument to suppress the trailing new‐
859                    line that echo would otherwise output.
860
861            \f      Output a form feed.
862
863            \n      Output a newline character.
864
865            \r      Output a carriage return.
866
867            \t      Output a (horizontal) tab character.
868
869            \v      Output a vertical tab.
870
871            \0digits
872                    Output the character whose value is given by zero to three
873                    octal digits.  If there are zero digits, a nul character
874                    is output.
875
876            \\      Output a backslash.
877
878            All other backslash sequences elicit undefined behaviour.
879
880     eval string ...
881            Concatenate all the arguments with spaces.  Then re-parse and exe‐
882            cute the command.
883
884     exec [command arg ...]
885            Unless command is omitted, the shell process is replaced with the
886            specified program (which must be a real program, not a shell
887            builtin or function).  Any redirections on the exec command are
888            marked as permanent, so that they are not undone when the exec
889            command finishes.
890
891     exit [exitstatus]
892            Terminate the shell process.  If exitstatus is given it is used as
893            the exit status of the shell; otherwise the exit status of the
894            preceding command is used.
895
896     export name ...
897
898     export -p
899            The specified names are exported so that they will appear in the
900            environment of subsequent commands.  The only way to un-export a
901            variable is to unset it.  The shell allows the value of a variable
902            to be set at the same time it is exported by writing
903
904                  export name=value
905
906            With no arguments the export command lists the names of all
907            exported variables.  With the -p option specified the output will
908            be formatted suitably for non-interactive use.
909
910     fc [-e editor] [first [last]]
911
912     fc -l [-nr] [first [last]]
913
914     fc -s [old=new] [first]
915            The fc builtin lists, or edits and re-executes, commands previ‐
916            ously entered to an interactive shell.
917
918            -e editor
919                   Use the editor named by editor to edit the commands.  The
920                   editor string is a command name, subject to search via the
921                   PATH variable.  The value in the FCEDIT variable is used as
922                   a default when -e is not specified.  If FCEDIT is null or
923                   unset, the value of the EDITOR variable is used.  If EDITOR
924                   is null or unset, ed(1) is used as the editor.
925
926            -l (ell)
927                   List the commands rather than invoking an editor on them.
928                   The commands are written in the sequence indicated by the
929                   first and last operands, as affected by -r, with each com‐
930                   mand preceded by the command number.
931
932            -n     Suppress command numbers when listing with -l.
933
934            -r     Reverse the order of the commands listed (with -l) or
935                   edited (with neither -l nor -s).
936
937            -s     Re-execute the command without invoking an editor.
938
939            first
940
941            last   Select the commands to list or edit.  The number of previ‐
942                   ous commands that can be accessed are determined by the
943                   value of the HISTSIZE variable.  The value of first or last
944                   or both are one of the following:
945
946                   [+]number
947                          A positive number representing a command number;
948                          command numbers can be displayed with the -l option.
949
950                   -number
951                          A negative decimal number representing the command
952                          that was executed number of commands previously.
953                          For example, -1 is the immediately previous command.
954
955            string
956                   A string indicating the most recently entered command that
957                   begins with that string.  If the old=new operand is not
958                   also specified with -s, the string form of the first oper‐
959                   and cannot contain an embedded equal sign.
960
961            The following environment variables affect the execution of fc:
962
963            FCEDIT    Name of the editor to use.
964
965            HISTSIZE  The number of previous commands that are accessible.
966
967     fg [job]
968            Move the specified job or the current job to the foreground.
969
970     getopts optstring var
971            The POSIX getopts command, not to be confused with the Bell Labs
972            -derived getopt(1).
973
974            The first argument should be a series of letters, each of which
975            may be optionally followed by a colon to indicate that the option
976            requires an argument.  The variable specified is set to the parsed
977            option.
978
979            The getopts command deprecates the older getopt(1) utility due to
980            its handling of arguments containing whitespace.
981
982            The getopts builtin may be used to obtain options and their argu‐
983            ments from a list of parameters.  When invoked, getopts places the
984            value of the next option from the option string in the list in the
985            shell variable specified by var and its index in the shell vari‐
986            able OPTIND.  When the shell is invoked, OPTIND is initialized to
987            1.  For each option that requires an argument, the getopts builtin
988            will place it in the shell variable OPTARG.  If an option is not
989            allowed for in the optstring, then OPTARG will be unset.
990
991            optstring is a string of recognized option letters (see
992            getopt(3)).  If a letter is followed by a colon, the option is
993            expected to have an argument which may or may not be separated
994            from it by white space.  If an option character is not found where
995            expected, getopts will set the variable var to a “?”; getopts will
996            then unset OPTARG and write output to standard error.  By specify‐
997            ing a colon as the first character of optstring all errors will be
998            ignored.
999
1000            A nonzero value is returned when the last option is reached.  If
1001            there are no remaining arguments, getopts will set var to the spe‐
1002            cial option, “--”, otherwise, it will set var to “?”.
1003
1004            The following code fragment shows how one might process the argu‐
1005            ments for a command that can take the options [a] and [b], and the
1006            option [c], which requires an argument.
1007
1008                  while getopts abc: f
1009                  do
1010                          case $f in
1011                          a | b)  flag=$f;;
1012                          c)      carg=$OPTARG;;
1013                          \?)     echo $USAGE; exit 1;;
1014                          esac
1015                  done
1016                  shift `expr $OPTIND - 1`
1017
1018            This code will accept any of the following as equivalent:
1019
1020                  cmd -acarg file file
1021                  cmd -a -c arg file file
1022                  cmd -carg -a file file
1023                  cmd -a -carg -- file file
1024
1025     hash -rv command ...
1026            The shell maintains a hash table which remembers the locations of
1027            commands.  With no arguments whatsoever, the hash command prints
1028            out the contents of this table.  Entries which have not been
1029            looked at since the last cd command are marked with an asterisk;
1030            it is possible for these entries to be invalid.
1031
1032            With arguments, the hash command removes the specified commands
1033            from the hash table (unless they are functions) and then locates
1034            them.  With the -v option, hash prints the locations of the com‐
1035            mands as it finds them.  The -r option causes the hash command to
1036            delete all the entries in the hash table except for functions.
1037
1038     pwd [-LP]
1039            builtin command remembers what the current directory is rather
1040            than recomputing it each time.  This makes it faster.  However, if
1041            the current directory is renamed, the builtin version of pwd will
1042            continue to print the old name for the directory.  The -P option
1043            causes the physical value of the current working directory to be
1044            shown, that is, all symbolic links are resolved to their respec‐
1045            tive values.  The -L option turns off the effect of any preceding
1046            -P options.
1047
1048     read [-p prompt] [-r] variable [...]
1049            The prompt is printed if the -p option is specified and the stan‐
1050            dard input is a terminal.  Then a line is read from the standard
1051            input.  The trailing newline is deleted from the line and the line
1052            is split as described in the section on word splitting above, and
1053            the pieces are assigned to the variables in order.  At least one
1054            variable must be specified.  If there are more pieces than vari‐
1055            ables, the remaining pieces (along with the characters in IFS that
1056            separated them) are assigned to the last variable.  If there are
1057            more variables than pieces, the remaining variables are assigned
1058            the null string.  The read builtin will indicate success unless
1059            EOF is encountered on input, in which case failure is returned.
1060
1061            By default, unless the -r option is specified, the backslash “\”
1062            acts as an escape character, causing the following character to be
1063            treated literally.  If a backslash is followed by a newline, the
1064            backslash and the newline will be deleted.
1065
1066     readonly name ...
1067
1068     readonly -p
1069            The specified names are marked as read only, so that they cannot
1070            be subsequently modified or unset.  The shell allows the value of
1071            a variable to be set at the same time it is marked read only by
1072            writing
1073
1074                  readonly name=value
1075
1076            With no arguments the readonly command lists the names of all read
1077            only variables.  With the -p option specified the output will be
1078            formatted suitably for non-interactive use.
1079
1080     printf format [arguments ...]
1081            printf formats and prints its arguments, after the first, under
1082            control of the format.  The format is a character string which
1083            contains three types of objects: plain characters, which are sim‐
1084            ply copied to standard output, character escape sequences which
1085            are converted and copied to the standard output, and format speci‐
1086            fications, each of which causes printing of the next successive
1087            argument.
1088
1089            The arguments after the first are treated as strings if the corre‐
1090            sponding format is either b, c or s; otherwise it is evaluated as
1091            a C constant, with the following extensions:
1092
1093                  ·   A leading plus or minus sign is allowed.
1094                  ·   If the leading character is a single or double quote,
1095                      the value is the ASCII code of the next character.
1096
1097            The format string is reused as often as necessary to satisfy the
1098            arguments.  Any extra format specifications are evaluated with
1099            zero or the null string.
1100
1101            Character escape sequences are in backslash notation as defined in
1102            ANSI X3.159-1989 (“ANSI C89”).  The characters and their meanings
1103            are as follows:
1104
1105                  \a      Write a <bell> character.
1106
1107                  \b      Write a <backspace> character.
1108
1109                  \f      Write a <form-feed> character.
1110
1111                  \n      Write a <new-line> character.
1112
1113                  \r      Write a <carriage return> character.
1114
1115                  \t      Write a <tab> character.
1116
1117                  \v      Write a <vertical tab> character.
1118
1119                  \\      Write a backslash character.
1120
1121                  \num    Write an 8-bit character whose ASCII value is the
1122                          1-, 2-, or 3-digit octal number num.
1123
1124            Each format specification is introduced by the percent character
1125            (``%'').  The remainder of the format specification includes, in
1126            the following order:
1127
1128            Zero or more of the following flags:
1129
1130                    #       A `#' character specifying that the value should
1131                            be printed in an ``alternative form''.  For b, c,
1132                            d, and s formats, this option has no effect.  For
1133                            the o format the precision of the number is
1134                            increased to force the first character of the out‐
1135                            put string to a zero.  For the x (X) format, a
1136                            non-zero result has the string 0x (0X) prepended
1137                            to it.  For e, E, f, g, and G formats, the result
1138                            will always contain a decimal point, even if no
1139                            digits follow the point (normally, a decimal point
1140                            only appears in the results of those formats if a
1141                            digit follows the decimal point).  For g and G
1142                            formats, trailing zeros are not removed from the
1143                            result as they would otherwise be.
1144
1145                    -       A minus sign `-' which specifies left adjustment
1146                            of the output in the indicated field;
1147
1148                    +       A `+' character specifying that there should
1149                            always be a sign placed before the number when
1150                            using signed formats.
1151
1152                    ‘ ’     A space specifying that a blank should be left
1153                            before a positive number for a signed format.  A
1154                            `+' overrides a space if both are used;
1155
1156                    0       A zero `0' character indicating that zero-padding
1157                            should be used rather than blank-padding.  A `-'
1158                            overrides a `0' if both are used;
1159
1160            Field Width:
1161                    An optional digit string specifying a field width; if the
1162                    output string has fewer characters than the field width it
1163                    will be blank-padded on the left (or right, if the left-
1164                    adjustment indicator has been given) to make up the field
1165                    width (note that a leading zero is a flag, but an embedded
1166                    zero is part of a field width);
1167
1168            Precision:
1169                    An optional period, ‘.’, followed by an optional digit
1170                    string giving a precision which specifies the number of
1171                    digits to appear after the decimal point, for e and f for‐
1172                    mats, or the maximum number of characters to be printed
1173                    from a string (b and s formats); if the digit string is
1174                    missing, the precision is treated as zero;
1175
1176            Format:
1177                    A character which indicates the type of format to use (one
1178                    of diouxXfwEgGbcs).
1179
1180            A field width or precision may be ‘*’ instead of a digit string.
1181            In this case an argument supplies the field width or precision.
1182
1183            The format characters and their meanings are:
1184
1185            diouXx      The argument is printed as a signed decimal (d or i),
1186                        unsigned octal, unsigned decimal, or unsigned hexadec‐
1187                        imal (X or x), respectively.
1188
1189            f           The argument is printed in the style [-]ddd.ddd where
1190                        the number of d's after the decimal point is equal to
1191                        the precision specification for the argument.  If the
1192                        precision is missing, 6 digits are given; if the pre‐
1193                        cision is explicitly 0, no digits and no decimal point
1194                        are printed.
1195
1196            eE          The argument is printed in the style [-]d.ddde±dd
1197                        where there is one digit before the decimal point and
1198                        the number after is equal to the precision specifica‐
1199                        tion for the argument; when the precision is missing,
1200                        6 digits are produced.  An upper-case E is used for an
1201                        `E' format.
1202
1203            gG          The argument is printed in style f or in style e (E)
1204                        whichever gives full precision in minimum space.
1205
1206            b           Characters from the string argument are printed with
1207                        backslash-escape sequences expanded.
1208                        The following additional backslash-escape sequences
1209                        are supported:
1210
1211                        \c      Causes dash to ignore any remaining characters
1212                                in the string operand containing it, any
1213                                remaining string operands, and any additional
1214                                characters in the format operand.
1215
1216                        \0num   Write an 8-bit character whose ASCII value is
1217                                the 1-, 2-, or 3-digit octal number num.
1218
1219            c           The first character of argument is printed.
1220
1221            s           Characters from the string argument are printed until
1222                        the end is reached or until the number of characters
1223                        indicated by the precision specification is reached;
1224                        if the precision is omitted, all characters in the
1225                        string are printed.
1226
1227            %           Print a `%'; no argument is used.
1228
1229            In no case does a non-existent or small field width cause trunca‐
1230            tion of a field; padding takes place only if the specified field
1231            width exceeds the actual width.
1232
1233     set [{ -options | +options | -- }] arg ...
1234            The set command performs three different functions.
1235
1236            With no arguments, it lists the values of all shell variables.
1237
1238            If options are given, it sets the specified option flags, or
1239            clears them as described in the section called Argument List
1240            Processing.  As a special case, if the option is -o or +o and no
1241            argument is supplied, the shell prints the settings of all its
1242            options.  If the option is -o, the settings are printed in a
1243            human-readable format; if the option is +o, the settings are
1244            printed in a format suitable for reinput to the shell to affect
1245            the same option settings.
1246
1247            The third use of the set command is to set the values of the
1248            shell's positional parameters to the specified args.  To change
1249            the positional parameters without changing any options, use “--”
1250            as the first argument to set.  If no args are present, the set
1251            command will clear all the positional parameters (equivalent to
1252            executing “shift $#”.)
1253
1254     shift [n]
1255            Shift the positional parameters n times.  A shift sets the value
1256            of $1 to the value of $2, the value of $2 to the value of $3, and
1257            so on, decreasing the value of $# by one.  If n is greater than
1258            the number of positional parameters, shift will issue an error
1259            message, and exit with return status 2.
1260
1261     test expression
1262
1263     [ expression ]
1264            The test utility evaluates the expression and, if it evaluates to
1265            true, returns a zero (true) exit status; otherwise it returns 1
1266            (false).  If there is no expression, test also returns 1 (false).
1267
1268            All operators and flags are separate arguments to the test util‐
1269            ity.
1270
1271            The following primaries are used to construct expression:
1272
1273            -b file       True if file exists and is a block special file.
1274
1275            -c file       True if file exists and is a character special file.
1276
1277            -d file       True if file exists and is a directory.
1278
1279            -e file       True if file exists (regardless of type).
1280
1281            -f file       True if file exists and is a regular file.
1282
1283            -g file       True if file exists and its set group ID flag is
1284                          set.
1285
1286            -h file       True if file exists and is a symbolic link.
1287
1288            -k file       True if file exists and its sticky bit is set.
1289
1290            -n string     True if the length of string is nonzero.
1291
1292            -p file       True if file is a named pipe (FIFO).
1293
1294            -r file       True if file exists and is readable.
1295
1296            -s file       True if file exists and has a size greater than
1297                          zero.
1298
1299            -t file_descriptor
1300                          True if the file whose file descriptor number is
1301                          file_descriptor is open and is associated with a
1302                          terminal.
1303
1304            -u file       True if file exists and its set user ID flag is set.
1305
1306            -w file       True if file exists and is writable.  True indicates
1307                          only that the write flag is on.  The file is not
1308                          writable on a read-only file system even if this
1309                          test indicates true.
1310
1311            -x file       True if file exists and is executable.  True indi‐
1312                          cates only that the execute flag is on.  If file is
1313                          a directory, true indicates that file can be
1314                          searched.
1315
1316            -z string     True if the length of string is zero.
1317
1318            -L file       True if file exists and is a symbolic link.  This
1319                          operator is retained for compatibility with previous
1320                          versions of this program.  Do not rely on its exis‐
1321                          tence; use -h instead.
1322
1323            -O file       True if file exists and its owner matches the effec‐
1324                          tive user id of this process.
1325
1326            -G file       True if file exists and its group matches the effec‐
1327                          tive group id of this process.
1328
1329            -S file       True if file exists and is a socket.
1330
1331            file1 -nt file2
1332                          True if file1 and file2 exist and file1 is newer
1333                          than file2.
1334
1335            file1 -ot file2
1336                          True if file1 and file2 exist and file1 is older
1337                          than file2.
1338
1339            file1 -ef file2
1340                          True if file1 and file2 exist and refer to the same
1341                          file.
1342
1343            string        True if string is not the null string.
1344
1345            s1 = s2       True if the strings s1 and s2 are identical.
1346
1347            s1 != s2      True if the strings s1 and s2 are not identical.
1348
1349            s1 < s2       True if string s1 comes before s2 based on the ASCII
1350                          value of their characters.
1351
1352            s1 > s2       True if string s1 comes after s2 based on the ASCII
1353                          value of their characters.
1354
1355            n1 -eq n2     True if the integers n1 and n2 are algebraically
1356                          equal.
1357
1358            n1 -ne n2     True if the integers n1 and n2 are not algebraically
1359                          equal.
1360
1361            n1 -gt n2     True if the integer n1 is algebraically greater than
1362                          the integer n2.
1363
1364            n1 -ge n2     True if the integer n1 is algebraically greater than
1365                          or equal to the integer n2.
1366
1367            n1 -lt n2     True if the integer n1 is algebraically less than
1368                          the integer n2.
1369
1370            n1 -le n2     True if the integer n1 is algebraically less than or
1371                          equal to the integer n2.
1372
1373            These primaries can be combined with the following operators:
1374
1375            ! expression  True if expression is false.
1376
1377            expression1 -a expression2
1378                          True if both expression1 and expression2 are true.
1379
1380            expression1 -o expression2
1381                          True if either expression1 or expression2 are true.
1382
1383            (expression)  True if expression is true.
1384
1385            The -a operator has higher precedence than the -o operator.
1386
1387     times  Print the accumulated user and system times for the shell and for
1388            processes run from the shell.  The return status is 0.
1389
1390     trap [action signal ...]
1391            Cause the shell to parse and execute action when any of the speci‐
1392            fied signals are received.  The signals are specified by signal
1393            number or as the name of the signal.  If signal is 0, the action
1394            is executed when the shell exits.  action may be null, which cause
1395            the specified signals to be ignored.  With action omitted or set
1396            to `-' the specified signals are set to their default action.
1397            When the shell forks off a subshell, it resets trapped (but not
1398            ignored) signals to the default action.  The trap command has no
1399            effect on signals that were ignored on entry to the shell.  trap
1400            without any arguments cause it to write a list of signals and
1401            their associated action to the standard output in a format that is
1402            suitable as an input to the shell that achieves the same trapping
1403            results.
1404
1405            Examples:
1406
1407                  trap
1408
1409            List trapped signals and their corresponding action
1410
1411                  trap '' INT QUIT tstp 30
1412
1413            Ignore signals INT QUIT TSTP USR1
1414
1415                  trap date INT
1416
1417            Print date upon receiving signal INT
1418
1419     type [name ...]
1420            Interpret each name as a command and print the resolution of the
1421            command search.  Possible resolutions are: shell keyword, alias,
1422            shell builtin, command, tracked alias and not found.  For aliases
1423            the alias expansion is printed; for commands and tracked aliases
1424            the complete pathname of the command is printed.
1425
1426     ulimit [-H | -S] [-a | -tfdscmlpn [value]]
1427            Inquire about or set the hard or soft limits on processes or set
1428            new limits.  The choice between hard limit (which no process is
1429            allowed to violate, and which may not be raised once it has been
1430            lowered) and soft limit (which causes processes to be signaled but
1431            not necessarily killed, and which may be raised) is made with
1432            these flags:
1433
1434            -H          set or inquire about hard limits
1435
1436            -S          set or inquire about soft limits.  If neither -H nor
1437                        -S is specified, the soft limit is displayed or both
1438                        limits are set.  If both are specified, the last one
1439                        wins.
1440
1441            The limit to be interrogated or set, then, is chosen by specifying
1442            any one of these flags:
1443
1444            -a          show all the current limits
1445
1446            -t          show or set the limit on CPU time (in seconds)
1447
1448            -f          show or set the limit on the largest file that can be
1449                        created (in 512-byte blocks)
1450
1451            -d          show or set the limit on the data segment size of a
1452                        process (in kilobytes)
1453
1454            -s          show or set the limit on the stack size of a process
1455                        (in kilobytes)
1456
1457            -c          show or set the limit on the largest core dump size
1458                        that can be produced (in 512-byte blocks)
1459
1460            -m          show or set the limit on the total physical memory
1461                        that can be in use by a process (in kilobytes)
1462
1463            -l          show or set the limit on how much memory a process can
1464                        lock with mlock(2) (in kilobytes)
1465
1466            -p          show or set the limit on the number of processes this
1467                        user can have at one time
1468
1469            -n          show or set the limit on the number files a process
1470                        can have open at once
1471
1472            If none of these is specified, it is the limit on file size that
1473            is shown or set.  If value is specified, the limit is set to that
1474            number; otherwise the current limit is displayed.
1475
1476            Limits of an arbitrary process can be displayed or set using the
1477            sysctl(8) utility.
1478
1479     umask [mask]
1480            Set the value of umask (see umask(2)) to the specified octal
1481            value.  If the argument is omitted, the umask value is printed.
1482
1483     unalias [-a] [name]
1484            If name is specified, the shell removes that alias.  If -a is
1485            specified, all aliases are removed.
1486
1487     unset [-fv] name ...
1488            The specified variables and functions are unset and unexported.
1489            If -f or -v is specified, the corresponding function or variable
1490            is unset, respectively.  If a given name corresponds to both a
1491            variable and a function, and no options are given, only the vari‐
1492            able is unset.
1493
1494     wait [job]
1495            Wait for the specified job to complete and return the exit status
1496            of the last process in the job.  If the argument is omitted, wait
1497            for all jobs to complete and the return an exit status of zero.
1498
1499   Command Line Editing
1500     When dash is being used interactively from a terminal, the current com‐
1501     mand and the command history (see fc in Builtins) can be edited using vi-
1502     mode command-line editing.  This mode uses commands, described below,
1503     similar to a subset of those described in the vi man page.  The command
1504     ‘set -o vi’ enables vi-mode editing and place sh into vi insert mode.
1505     With vi-mode enabled, sh can be switched between insert mode and command
1506     mode.  The editor is not described in full here, but will be in a later
1507     document.  It's similar to vi: typing ⟨ESC⟩ will throw you into command
1508     VI command mode.  Hitting ⟨return⟩ while in command mode will pass the
1509     line to the shell.
1510

EXIT STATUS

1512     Errors that are detected by the shell, such as a syntax error, will cause
1513     the shell to exit with a non-zero exit status.  If the shell is not an
1514     interactive shell, the execution of the shell file will be aborted.  Oth‐
1515     erwise the shell will return the exit status of the last command exe‐
1516     cuted, or if the exit builtin is used with a numeric argument, it will
1517     return the argument.
1518

ENVIRONMENT

1520     HOME       Set automatically by login(1) from the user's login directory
1521                in the password file (passwd(4)).  This environment variable
1522                also functions as the default argument for the cd builtin.
1523
1524     PATH       The default search path for executables.  See the above sec‐
1525                tion Path Search.
1526
1527     CDPATH     The search path used with the cd builtin.
1528
1529     MAIL       The name of a mail file, that will be checked for the arrival
1530                of new mail.  Overridden by MAILPATH.
1531
1532     MAILCHECK  The frequency in seconds that the shell checks for the arrival
1533                of mail in the files specified by the MAILPATH or the MAIL
1534                file.  If set to 0, the check will occur at each prompt.
1535
1536     MAILPATH   A colon “:” separated list of file names, for the shell to
1537                check for incoming mail.  This environment setting overrides
1538                the MAIL setting.  There is a maximum of 10 mailboxes that can
1539                be monitored at once.
1540
1541     PS1        The primary prompt string, which defaults to “$  ”, unless you
1542                are the superuser, in which case it defaults to “#  ”.
1543
1544     PS2        The secondary prompt string, which defaults to “>  ”.
1545
1546     PS4        Output before each line when execution trace (set -x) is
1547                enabled, defaults to “+  ”.
1548
1549     IFS        Input Field Separators.  This is normally set to ⟨space⟩,
1550                ⟨tab⟩, and ⟨newline⟩.  See the White Space Splitting section
1551                for more details.
1552
1553     TERM       The default terminal setting for the shell.  This is inherited
1554                by children of the shell, and is used in the history editing
1555                modes.
1556
1557     HISTSIZE   The number of lines in the history buffer for the shell.
1558
1559     PWD        The logical value of the current working directory.  This is
1560                set by the cd command.
1561
1562     OLDPWD     The previous logical value of the current working directory.
1563                This is set by the cd command.
1564
1565     PPID       The process ID of the parent process of the shell.
1566

FILES

1568     $HOME/.profile
1569
1570     /etc/profile
1571

SEE ALSO

1573     csh(1), echo(1), getopt(1), ksh(1), login(1), printf(1), test(1),
1574     getopt(3), passwd(5), environ(7), sysctl(8)
1575

HISTORY

1577     dash is a POSIX-compliant implementation of /bin/sh that aims to be as
1578     small as possible.  dash is a direct descendant of the NetBSD version of
1579     ash (the Almquist SHell), ported to Linux in early 1997.  It was renamed
1580     to dash in 2002.
1581

BUGS

1583     Setuid shell scripts should be avoided at all costs, as they are a sig‐
1584     nificant security risk.
1585
1586     PS1, PS2, and PS4 should be subject to parameter expansion before being
1587     displayed.
1588
1589BSD                            January 19, 2003                            BSD
Impressum