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 between 0 and 9, as in ‘3’ (not ‘[3]’), that refers to a file
236     descriptor.
237
238           [n]> file   Redirect standard output (or n) to file.
239
240           [n]>| file  Same, but override the -C option.
241
242           [n]>> file  Append standard output (or n) to file.
243
244           [n]< file   Redirect standard input (or n) from file.
245
246           [n1]<&n2    Copy file descriptor n2 as stdout (or fd n1).  fd n2.
247
248           [n]<&-      Close standard input (or n).
249
250           [n1]>&n2    Copy file descriptor n2 as stdin (or fd n1).  fd 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 proceeds 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 if and only if the exit status
415     of the first command is zero.  “||” is similar, but executes the second
416     command if and only if the exit status of the first command is nonzero.
417     “&&” and “||” both 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.  The “(” character before
468     the pattern is optional.
469
470   Grouping Commands Together
471     Commands may be grouped by writing either
472
473           (list)
474
475     or
476
477           { list; }
478
479     The first of these executes the commands in a subshell.  Builtin commands
480     grouped into a (list) will not affect the current shell.  The second form
481     does not fork another shell so is slightly more efficient.  Grouping com‐
482     mands together this way allows you to redirect their output as though
483     they were one program:
484
485           { printf " hello " ; printf " world\n" ; } > greeting
486
487     Note that “}” must follow a control operator (here, “;”) so that it is
488     recognized as a reserved word and not as another command argument.
489
490   Functions
491     The syntax of a function definition is
492
493           name () command
494
495     A function definition is an executable statement; when executed it
496     installs a function named name and returns an exit status of zero.  The
497     command is normally a list enclosed between “{” and “}”.
498
499     Variables may be declared to be local to a function by using a local com‐
500     mand.  This should appear as the first statement of a function, and the
501     syntax is
502
503           local [variable | -] ...
504
505     Local is implemented as a builtin command.
506
507     When a variable is made local, it inherits the initial value and exported
508     and readonly flags from the variable with the same name in the surround‐
509     ing scope, if there is one.  Otherwise, the variable is initially unset.
510     The shell uses dynamic scoping, so that if you make the variable x local
511     to function f, which then calls function g, references to the variable x
512     made inside g will refer to the variable x declared inside f, not to the
513     global variable named x.
514
515     The only special parameter that can be made local is “-”.  Making “-”
516     local any shell options that are changed via the set command inside the
517     function to be restored to their original values when the function
518     returns.
519
520     The syntax of the return command is
521
522           return [exitstatus]
523
524     It terminates the currently executing function.  Return is implemented as
525     a builtin command.
526
527   Variables and Parameters
528     The shell maintains a set of parameters.  A parameter denoted by a name
529     is called a variable.  When starting up, the shell turns all the environ‐
530     ment variables into shell variables.  New variables can be set using the
531     form
532
533           name=value
534
535     Variables set by the user must have a name consisting solely of alphabet‐
536     ics, numerics, and underscores - the first of which must not be numeric.
537     A parameter can also be denoted by a number or a special character as
538     explained below.
539
540   Positional Parameters
541     A positional parameter is a parameter denoted by a number (n > 0).  The
542     shell sets these initially to the values of its command line arguments
543     that follow the name of the shell script.  The set builtin can also be
544     used to set or reset them.
545
546   Special Parameters
547     A special parameter is a parameter denoted by one of the following spe‐
548     cial characters.  The value of the parameter is listed next to its char‐
549     acter.
550
551     *            Expands to the positional parameters, starting from one.
552                  When the expansion occurs within a double-quoted string it
553                  expands to a single field with the value of each parameter
554                  separated by the first character of the IFS variable, or by
555                  a ⟨space⟩ if IFS is unset.
556
557     @            Expands to the positional parameters, starting from one.
558                  When the expansion occurs within double-quotes, each posi‐
559                  tional parameter expands as a separate argument.  If there
560                  are no positional parameters, the expansion of @ generates
561                  zero arguments, even when @ is double-quoted.  What this
562                  basically means, for example, is if $1 is “abc” and $2 is
563                  “def ghi”, then "$@" expands to the two arguments:
564
565                        "abc" "def ghi"
566
567     #            Expands to the number of positional parameters.
568
569     ?            Expands to the exit status of the most recent pipeline.
570
571     - (Hyphen.)  Expands to the current option flags (the single-letter
572                  option names concatenated into a string) as specified on
573                  invocation, by the set builtin command, or implicitly by the
574                  shell.
575
576     $            Expands to the process ID of the invoked shell.  A subshell
577                  retains the same value of $ as its parent.
578
579     !            Expands to the process ID of the most recent background com‐
580                  mand executed from the current shell.  For a pipeline, the
581                  process ID is that of the last command in the pipeline.
582
583     0 (Zero.)    Expands to the name of the shell or shell script.
584
585   Word Expansions
586     This clause describes the various expansions that are performed on words.
587     Not all expansions are performed on every word, as explained later.
588
589     Tilde expansions, parameter expansions, command substitutions, arithmetic
590     expansions, and quote removals that occur within a single word expand to
591     a single field.  It is only field splitting or pathname expansion that
592     can create multiple fields from a single word.  The single exception to
593     this rule is the expansion of the special parameter @ within double-
594     quotes, as was described above.
595
596     The order of word expansion is:
597
598     1.   Tilde Expansion, Parameter Expansion, Command Substitution, Arith‐
599          metic Expansion (these all occur at the same time).
600
601     2.   Field Splitting is performed on fields generated by step (1) unless
602          the IFS variable is null.
603
604     3.   Pathname Expansion (unless set -f is in effect).
605
606     4.   Quote Removal.
607
608     The $ character is used to introduce parameter expansion, command substi‐
609     tution, or arithmetic evaluation.
610
611   Tilde Expansion (substituting a user's home directory)
612     A word beginning with an unquoted tilde character (~) is subjected to
613     tilde expansion.  All the characters up to a slash (/) or the end of the
614     word are treated as a username and are replaced with the user's home
615     directory.  If the username is missing (as in ~/foobar), the tilde is
616     replaced with the value of the HOME variable (the current user's home
617     directory).
618
619   Parameter Expansion
620     The format for parameter expansion is as follows:
621
622           ${expression}
623
624     where expression consists of all characters until the matching “}”.  Any
625     “}” escaped by a backslash or within a quoted string, and characters in
626     embedded arithmetic expansions, command substitutions, and variable
627     expansions, are not examined in determining the matching “}”.
628
629     The simplest form for parameter expansion is:
630
631           ${parameter}
632
633     The value, if any, of parameter is substituted.
634
635     The parameter name or symbol can be enclosed in braces, which are
636     optional except for positional parameters with more than one digit or
637     when parameter is followed by a character that could be interpreted as
638     part of the name.  If a parameter expansion occurs inside double-quotes:
639
640     1.   Pathname expansion is not performed on the results of the expansion.
641
642     2.   Field splitting is not performed on the results of the expansion,
643          with the exception of @.
644
645     In addition, a parameter expansion can be modified by using one of the
646     following formats.
647
648     ${parameter:-word}    Use Default Values.  If parameter is unset or null,
649                           the expansion of word is substituted; otherwise,
650                           the value of parameter is substituted.
651
652     ${parameter:=word}    Assign Default Values.  If parameter is unset or
653                           null, the expansion of word is assigned to parame‐
654                           ter.  In all cases, the final value of parameter is
655                           substituted.  Only variables, not positional param‐
656                           eters or special parameters, can be assigned in
657                           this way.
658
659     ${parameter:?[word]}  Indicate Error if Null or Unset.  If parameter is
660                           unset or null, the expansion of word (or a message
661                           indicating it is unset if word is omitted) is writ‐
662                           ten to standard error and the shell exits with a
663                           nonzero exit status.  Otherwise, the value of
664                           parameter is substituted.  An interactive shell
665                           need not exit.
666
667     ${parameter:+word}    Use Alternative Value.  If parameter is unset or
668                           null, null is substituted; otherwise, the expansion
669                           of word is substituted.
670
671     In the parameter expansions shown previously, use of the colon in the
672     format results in a test for a parameter that is unset or null; omission
673     of the colon results in a test for a parameter that is only unset.
674
675     ${#parameter}         String Length.  The length in characters of the
676                           value of parameter.
677
678     The following four varieties of parameter expansion provide for substring
679     processing.  In each case, pattern matching notation (see Shell
680     Patterns), rather than regular expression notation, is used to evaluate
681     the patterns.  If parameter is * or @, the result of the expansion is
682     unspecified.  Enclosing the full parameter expansion string in double-
683     quotes does not cause the following four varieties of pattern characters
684     to be quoted, whereas quoting characters within the braces has this
685     effect.
686
687     ${parameter%word}     Remove Smallest Suffix Pattern.  The word is
688                           expanded to produce a pattern.  The parameter
689                           expansion then results in parameter, with the
690                           smallest portion of the suffix matched by the pat‐
691                           tern deleted.
692
693     ${parameter%%word}    Remove Largest Suffix Pattern.  The word is
694                           expanded to produce a pattern.  The parameter
695                           expansion then results in parameter, with the
696                           largest portion of the suffix matched by the pat‐
697                           tern deleted.
698
699     ${parameter#word}     Remove Smallest Prefix Pattern.  The word is
700                           expanded to produce a pattern.  The parameter
701                           expansion then results in parameter, with the
702                           smallest portion of the prefix matched by the pat‐
703                           tern deleted.
704
705     ${parameter##word}    Remove Largest Prefix Pattern.  The word is
706                           expanded to produce a pattern.  The parameter
707                           expansion then results in parameter, with the
708                           largest portion of the prefix matched by the pat‐
709                           tern deleted.
710
711   Command Substitution
712     Command substitution allows the output of a command to be substituted in
713     place of the command name itself.  Command substitution occurs when the
714     command is enclosed as follows:
715
716           $(command)
717
718     or (“backquoted” version):
719
720           `command`
721
722     The shell expands the command substitution by executing command in a sub‐
723     shell environment and replacing the command substitution with the stan‐
724     dard output of the command, removing sequences of one or more ⟨newline⟩s
725     at the end of the substitution.  (Embedded ⟨newline⟩s before the end of
726     the output are not removed; however, during field splitting, they may be
727     translated into ⟨space⟩s, depending on the value of IFS and quoting that
728     is in effect.)
729
730   Arithmetic Expansion
731     Arithmetic expansion provides a mechanism for evaluating an arithmetic
732     expression and substituting its value.  The format for arithmetic expan‐
733     sion is as follows:
734
735           $((expression))
736
737     The expression is treated as if it were in double-quotes, except that a
738     double-quote inside the expression is not treated specially.  The shell
739     expands all tokens in the expression for parameter expansion, command
740     substitution, and quote removal.
741
742     Next, the shell treats this as an arithmetic expression and substitutes
743     the value of the expression.
744
745   White Space Splitting (Field Splitting)
746     After parameter expansion, command substitution, and arithmetic expansion
747     the shell scans the results of expansions and substitutions that did not
748     occur in double-quotes for field splitting and multiple fields can
749     result.
750
751     The shell treats each character of the IFS as a delimiter and uses the
752     delimiters to split the results of parameter expansion and command sub‐
753     stitution into fields.
754
755   Pathname Expansion (File Name Generation)
756     Unless the -f flag is set, file name generation is performed after word
757     splitting is complete.  Each word is viewed as a series of patterns, sep‐
758     arated by slashes.  The process of expansion replaces the word with the
759     names of all existing files whose names can be formed by replacing each
760     pattern with a string that matches the specified pattern.  There are two
761     restrictions on this: first, a pattern cannot match a string containing a
762     slash, and second, a pattern cannot match a string starting with a period
763     unless the first character of the pattern is a period.  The next section
764     describes the patterns used for both Pathname Expansion and the case com‐
765     mand.
766
767   Shell Patterns
768     A pattern consists of normal characters, which match themselves, and
769     meta-characters.  The meta-characters are “!”, “*”, “?”, and “[”.  These
770     characters lose their special meanings if they are quoted.  When command
771     or variable substitution is performed and the dollar sign or back quotes
772     are not double quoted, the value of the variable or the output of the
773     command is scanned for these characters and they are turned into meta-
774     characters.
775
776     An asterisk (“*”) matches any string of characters.  A question mark
777     matches any single character.  A left bracket (“[”) introduces a charac‐
778     ter class.  The end of the character class is indicated by a (“]”); if
779     the “]” is missing then the “[” matches a “[” rather than introducing a
780     character class.  A character class matches any of the characters between
781     the square brackets.  A range of characters may be specified using a
782     minus sign.  The character class may be complemented by making an excla‐
783     mation point the first character of the character class.
784
785     To include a “]” in a character class, make it the first character listed
786     (after the “!”, if any).  To include a minus sign, make it the first or
787     last character listed.
788
789   Builtins
790     This section lists the builtin commands which are builtin because they
791     need to perform some operation that can't be performed by a separate
792     process.  In addition to these, there are several other commands that may
793     be builtin for efficiency (e.g.  printf(1), echo(1), test(1), etc).
794
795     :
796
797     true   A null command that returns a 0 (true) exit value.
798
799     . file
800            The commands in the specified file are read and executed by the
801            shell.
802
803     alias [name[=string ...]]
804            If name=string is specified, the shell defines the alias name with
805            value string.  If just name is specified, the value of the alias
806            name is printed.  With no arguments, the alias builtin prints the
807            names and values of all defined aliases (see unalias).
808
809     bg [job] ...
810            Continue the specified jobs (or the current job if no jobs are
811            given) in the background.
812
813     command [-p] [-v] [-V] command [arg ...]
814            Execute the specified command but ignore shell functions when
815            searching for it.  (This is useful when you have a shell function
816            with the same name as a builtin command.)
817
818            -p     search for command using a PATH that guarantees to find all
819                   the standard utilities.
820
821            -V     Do not execute the command but search for the command and
822                   print the resolution of the command search.  This is the
823                   same as the type builtin.
824
825            -v     Do not execute the command but search for the command and
826                   print the absolute pathname of utilities, the name for
827                   builtins or the expansion of aliases.
828
829     cd -
830
831     cd [-LP] [directory]
832            Switch to the specified directory (default HOME).  If an entry for
833            CDPATH appears in the environment of the cd command or the shell
834            variable CDPATH is set and the directory name does not begin with
835            a slash, then the directories listed in CDPATH will be searched
836            for the specified directory.  The format of CDPATH is the same as
837            that of PATH.  If a single dash is specified as the argument, it
838            will be replaced by the value of OLDPWD.  The cd command will
839            print out the name of the directory that it actually switched to
840            if this is different from the name that the user gave.  These may
841            be different either because the CDPATH mechanism was used or
842            because the argument is a single dash.  The -P option causes the
843            physical directory structure to be used, that is, all symbolic
844            links are resolved to their respective values.  The -L option
845            turns off the effect of any preceding -P options.
846
847     echo [-n] args...
848            Print the arguments on the standard output, separated by spaces.
849            Unless the -n option is present, a newline is output following the
850            arguments.
851
852            If any of the following sequences of characters is encountered
853            during output, the sequence is not output.  Instead, the specified
854            action is performed:
855
856            \b      A backspace character is output.
857
858            \c      Subsequent output is suppressed.  This is normally used at
859                    the end of the last argument to suppress the trailing new‐
860                    line that echo would otherwise output.
861
862            \f      Output a form feed.
863
864            \n      Output a newline character.
865
866            \r      Output a carriage return.
867
868            \t      Output a (horizontal) tab character.
869
870            \v      Output a vertical tab.
871
872            \0digits
873                    Output the character whose value is given by zero to three
874                    octal digits.  If there are zero digits, a nul character
875                    is output.
876
877            \\      Output a backslash.
878
879            All other backslash sequences elicit undefined behaviour.
880
881     eval string ...
882            Concatenate all the arguments with spaces.  Then re-parse and exe‐
883            cute the command.
884
885     exec [command arg ...]
886            Unless command is omitted, the shell process is replaced with the
887            specified program (which must be a real program, not a shell
888            builtin or function).  Any redirections on the exec command are
889            marked as permanent, so that they are not undone when the exec
890            command finishes.
891
892     exit [exitstatus]
893            Terminate the shell process.  If exitstatus is given it is used as
894            the exit status of the shell; otherwise the exit status of the
895            preceding command is used.
896
897     export name ...
898
899     export -p
900            The specified names are exported so that they will appear in the
901            environment of subsequent commands.  The only way to un-export a
902            variable is to unset it.  The shell allows the value of a variable
903            to be set at the same time it is exported by writing
904
905                  export name=value
906
907            With no arguments the export command lists the names of all
908            exported variables.  With the -p option specified the output will
909            be formatted suitably for non-interactive use.
910
911     fc [-e editor] [first [last]]
912
913     fc -l [-nr] [first [last]]
914
915     fc -s [old=new] [first]
916            The fc builtin lists, or edits and re-executes, commands previ‐
917            ously entered to an interactive shell.
918
919            -e editor
920                   Use the editor named by editor to edit the commands.  The
921                   editor string is a command name, subject to search via the
922                   PATH variable.  The value in the FCEDIT variable is used as
923                   a default when -e is not specified.  If FCEDIT is null or
924                   unset, the value of the EDITOR variable is used.  If EDITOR
925                   is null or unset, ed(1) is used as the editor.
926
927            -l (ell)
928                   List the commands rather than invoking an editor on them.
929                   The commands are written in the sequence indicated by the
930                   first and last operands, as affected by -r, with each com‐
931                   mand preceded by the command number.
932
933            -n     Suppress command numbers when listing with -l.
934
935            -r     Reverse the order of the commands listed (with -l) or
936                   edited (with neither -l nor -s).
937
938            -s     Re-execute the command without invoking an editor.
939
940            first
941
942            last   Select the commands to list or edit.  The number of previ‐
943                   ous commands that can be accessed are determined by the
944                   value of the HISTSIZE variable.  The value of first or last
945                   or both are one of the following:
946
947                   [+]number
948                          A positive number representing a command number;
949                          command numbers can be displayed with the -l option.
950
951                   -number
952                          A negative decimal number representing the command
953                          that was executed number of commands previously.
954                          For example, -1 is the immediately previous command.
955
956            string
957                   A string indicating the most recently entered command that
958                   begins with that string.  If the old=new operand is not
959                   also specified with -s, the string form of the first oper‐
960                   and cannot contain an embedded equal sign.
961
962            The following environment variables affect the execution of fc:
963
964            FCEDIT    Name of the editor to use.
965
966            HISTSIZE  The number of previous commands that are accessible.
967
968     fg [job]
969            Move the specified job or the current job to the foreground.
970
971     getopts optstring var
972            The POSIX getopts command, not to be confused with the Bell Labs
973            -derived getopt(1).
974
975            The first argument should be a series of letters, each of which
976            may be optionally followed by a colon to indicate that the option
977            requires an argument.  The variable specified is set to the parsed
978            option.
979
980            The getopts command deprecates the older getopt(1) utility due to
981            its handling of arguments containing whitespace.
982
983            The getopts builtin may be used to obtain options and their argu‐
984            ments from a list of parameters.  When invoked, getopts places the
985            value of the next option from the option string in the list in the
986            shell variable specified by var and its index in the shell vari‐
987            able OPTIND.  When the shell is invoked, OPTIND is initialized to
988            1.  For each option that requires an argument, the getopts builtin
989            will place it in the shell variable OPTARG.  If an option is not
990            allowed for in the optstring, then OPTARG will be unset.
991
992            optstring is a string of recognized option letters (see
993            getopt(3)).  If a letter is followed by a colon, the option is
994            expected to have an argument which may or may not be separated
995            from it by white space.  If an option character is not found where
996            expected, getopts will set the variable var to a “?”; getopts will
997            then unset OPTARG and write output to standard error.  By specify‐
998            ing a colon as the first character of optstring all errors will be
999            ignored.
1000
1001            After the last option getopts will return a non-zero value and set
1002            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 bytes to be printed from a
1173                    string (b and s formats); if the digit string is missing,
1174                    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 bytes indi‐
1223                        cated by the precision specification is reached; if
1224                        the precision is omitted, all characters in the string
1225                        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 or EXIT, the
1394            action is executed when the shell exits.  action may be empty
1395            (''), which causes the specified signals to be ignored.  With
1396            action omitted or set to `-' the specified signals are set to
1397            their default action.  When the shell forks off a subshell, it
1398            resets trapped (but not ignored) signals to the default action.
1399            The trap command has no effect on signals that were ignored on
1400            entry to the shell.  trap without any arguments cause it to write
1401            a list of signals and their associated action to the standard out‐
1402            put in a format that is suitable as an input to the shell that
1403            achieves the same trapping 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 | -tfdscmlpnv [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            -v          show or set the limit on the total virtual memory that
1473                        can be in use by a process (in kilobytes)
1474
1475            -r          show or set the limit on the real-time scheduling pri‐
1476                        ority of a process
1477
1478            If none of these is specified, it is the limit on file size that
1479            is shown or set.  If value is specified, the limit is set to that
1480            number; otherwise the current limit is displayed.
1481
1482            Limits of an arbitrary process can be displayed or set using the
1483            sysctl(8) utility.
1484
1485     umask [mask]
1486            Set the value of umask (see umask(2)) to the specified octal
1487            value.  If the argument is omitted, the umask value is printed.
1488
1489     unalias [-a] [name]
1490            If name is specified, the shell removes that alias.  If -a is
1491            specified, all aliases are removed.
1492
1493     unset [-fv] name ...
1494            The specified variables and functions are unset and unexported.
1495            If -f or -v is specified, the corresponding function or variable
1496            is unset, respectively.  If a given name corresponds to both a
1497            variable and a function, and no options are given, only the vari‐
1498            able is unset.
1499
1500     wait [job]
1501            Wait for the specified job to complete and return the exit status
1502            of the last process in the job.  If the argument is omitted, wait
1503            for all jobs to complete and return an exit status of zero.
1504
1505   Command Line Editing
1506     When dash is being used interactively from a terminal, the current com‐
1507     mand and the command history (see fc in Builtins) can be edited using vi-
1508     mode command-line editing.  This mode uses commands, described below,
1509     similar to a subset of those described in the vi man page.  The command
1510     ‘set -o vi’ enables vi-mode editing and places sh into vi insert mode.
1511     With vi-mode enabled, sh can be switched between insert mode and command
1512     mode.  It is similar to vi: typing ⟨ESC⟩ enters vi command mode.  Hitting
1513     ⟨return⟩ while in command mode will pass the line to the shell.
1514

EXIT STATUS

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

ENVIRONMENT

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

FILES

1572     $HOME/.profile
1573
1574     /etc/profile
1575

SEE ALSO

1577     csh(1), echo(1), getopt(1), ksh(1), login(1), printf(1), test(1),
1578     getopt(3), passwd(5), environ(7), sysctl(8)
1579

HISTORY

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

BUGS

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