1
.\" Copyright (c) 1991, 1993
2
.\" The Regents of the University of California. All rights reserved.
3
.\" Copyright (c) 1997-2005
4
.\" Herbert Xu <herbert@gondor.apana.org.au>. All rights reserved.
6
.\" This code is derived from software contributed to Berkeley by
9
.\" Redistribution and use in source and binary forms, with or without
10
.\" modification, are permitted provided that the following conditions
12
.\" 1. Redistributions of source code must retain the above copyright
13
.\" notice, this list of conditions and the following disclaimer.
14
.\" 2. Redistributions in binary form must reproduce the above copyright
15
.\" notice, this list of conditions and the following disclaimer in the
16
.\" documentation and/or other materials provided with the distribution.
17
.\" 3. Neither the name of the University nor the names of its contributors
18
.\" may be used to endorse or promote products derived from this software
19
.\" without specific prior written permission.
21
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
40
.Nd command interpreter (shell)
44
.Op Fl aCefnuvxIimqVEb
45
.Op Cm +aCefnuvxIimqVEb
48
.Op Fl o Ar option_name
49
.Op Cm +o Ar option_name
52
.Op Ar command_file Oo Ar argument ... Oc
57
.Op Fl aCefnuvxIimqVEb
58
.Op Cm +aCefnuvxIimqVEb
61
.Op Fl o Ar option_name
62
.Op Cm +o Ar option_name
66
.Op Ar command_name Oo Ar argument ... Oc
71
.Op Fl aCefnuvxIimqVEb
72
.Op Cm +aCefnuvxIimqVEb
75
.Op Fl o Ar option_name
76
.Op Cm +o Ar option_name
83
is the standard command interpreter for the system.
84
The current version of
86
is in the process of being changed to conform with the
88
1003.2 and 1003.2a specifications for the shell.
90
features which make it appear similar in some respects to the Korn shell,
91
but it is not a Korn shell clone (see
93
Only features designated by
95
plus a few Berkeley extensions, are being incorporated into this shell.
98
conformance by the time 4.4 BSD is released.
99
This man page is not intended
100
to be a tutorial or a complete specification of the shell.
102
The shell is a command that reads lines from either a file or the
103
terminal, interprets them, and generally executes other commands.
104
It is the program that is running when a user logs into the system
105
(although a user can select a different shell with the
108
The shell implements a language that has flow control
109
constructs, a macro facility that provides a variety of features in
110
addition to data storage, along with built in history and line editing
112
It incorporates many features to aid interactive use and
113
has the advantage that the interpretative language is common to both
114
interactive and non-interactive use (shell scripts).
116
can be typed directly to the running shell or can be put into a file and
117
the file can be executed directly by the shell.
119
If no args are present and if the standard input of the shell
120
is connected to a terminal (or if the
125
option is not present, the shell is considered an interactive shell.
126
An interactive shell generally prompts before each command and handles
127
programming and command errors differently (as described below).
129
the shell inspects argument 0, and if it begins with a dash
131
the shell is also considered
133
This is normally done automatically by the system
134
when the user first logs in.
135
A login shell first reads commands
141
If the environment variable
143
is set on entry to an interactive shell, or is set in the
145
of a login shell, the shell next reads
146
commands from the file named in
148
Therefore, a user should place commands that are to be executed only at
151
file, and commands that are executed for every interactive shell inside the
156
variable to some file, place the following line in your
158
of your home directory
160
.Dl ENV=$HOME/.shinit; export ENV
164
any filename you wish.
166
If command line arguments besides the options have been specified, then
167
the shell treats the first argument as the name of a file from which to
168
read commands (a shell script), and the remaining arguments are set as the
169
positional parameters of the shell ($1, $2, etc).
171
reads commands from its standard input.
172
.Ss Argument List Processing
173
All of the single letter options have a corresponding name that can be
174
used as an argument to the
179
name is provided next to the single letter option in
180
the description below.
183
turns the option on, while using a plus
186
The following options can be set from the command line or
189
builtin (described later).
190
.Bl -tag -width aaaallexportfoo -offset indent
191
.It Fl a Em allexport
192
Export all variables assigned to.
194
Read commands from the
196
operand instead of from the standard input.
197
Special parameter 0 will be set from the
199
operand and the positional parameters ($1, $2, etc.)
200
set from the remaining argument operands.
201
.It Fl C Em noclobber
202
Don't overwrite existing files with
205
If not interactive, exit immediately if any untested command fails.
206
The exit status of a command is considered to be
207
explicitly tested if the command is used to control an
213
or if the command is the left hand operand of an
219
Disable pathname expansion.
221
If not interactive, read commands but do not execute them.
222
This is useful for checking the syntax of shell scripts.
224
Write a message to standard error when attempting to expand a variable
225
that is not set, and if the shell is not interactive, exit immediately.
227
The shell writes its input to standard error as it is read.
228
Useful for debugging.
230
Write each command to standard error (preceded by a
232
before it is executed.
233
Useful for debugging.
234
.It Fl I Em ignoreeof
235
Ignore EOF's from input when interactive.
236
.It Fl i Em interactive
237
Force the shell to behave interactively.
239
Turn on job control (set automatically when interactive).
241
Read commands from standard input (set automatically if no file arguments
243
This option has no effect when set after the shell has
244
already started running (i.e. with
249
command line editor (disables
255
command line editor (disables
259
Enable asynchronous notification of background job completion.
260
(UNIMPLEMENTED for 4.4alpha)
262
.Ss Lexical Structure
263
The shell reads input in terms of lines from a file and breaks it up into
264
words at whitespace (blanks and tabs), and at certain sequences of
265
characters that are special to the shell called
267
There are two types of operators: control operators and redirection
268
operators (their meaning is discussed later).
269
Following is a list of operators:
270
.Bl -ohang -offset indent
271
.It "Control operators:"
272
.Dl & && \&( \&) \&; ;; | || \*[Lt]newline\*[Gt]
273
.It "Redirection operators:"
274
.Dl \*[Lt] \*[Gt] \*[Gt]| \*[Lt]\*[Lt] \*[Gt]\*[Gt] \*[Lt]& \*[Gt]& \*[Lt]\*[Lt]- \*[Lt]\*[Gt]
277
Quoting is used to remove the special meaning of certain characters or
278
words to the shell, such as operators, whitespace, or keywords.
279
There are three types of quoting: matched single quotes,
280
matched double quotes, and backslash.
282
A backslash preserves the literal meaning of the following
283
character, with the exception of
285
A backslash preceding a
287
is treated as a line continuation.
289
Enclosing characters in single quotes preserves the literal meaning of all
290
the characters (except single quotes, making it impossible to put
291
single-quotes in a single-quoted string).
293
Enclosing characters within double quotes preserves the literal
294
meaning of all characters except dollarsign
300
The backslash inside double quotes is historically weird, and serves to
301
quote only the following characters:
302
.Dl $ ` \*q \e \*[Lt]newline\*[Gt] .
303
Otherwise it remains literal.
305
Reserved words are words that have special meaning to the
306
shell and are recognized at the beginning of a line and
307
after a control operator.
308
The following are reserved words:
309
.Bl -column while while while while while -offset indent
310
.It ! Ta elif Ta fi Ta while Ta case
311
.It else Ta for Ta then Ta { Ta }
312
.It do Ta done Ta until Ta if Ta esac
315
Their meaning is discussed later.
317
An alias is a name and corresponding value set using the
320
Whenever a reserved word may occur (see above),
321
and after checking for reserved words, the shell
322
checks the word to see if it matches an alias.
323
If it does, it replaces it in the input stream with its value.
324
For example, if there is an alias called
330
.Dl lf foobar Aq return
334
.Dl ls -F foobar Aq return
336
Aliases provide a convenient way for naive users to create shorthands for
337
commands without having to learn how to create functions with arguments.
338
They can also be used to create lexically obscure code.
339
This use is discouraged.
341
The shell interprets the words it reads according to a language, the
342
specification of which is outside the scope of this man page (refer to the
346
Essentially though, a line is read and if the first
347
word of the line (or after a control operator) is not a reserved word,
348
then the shell has recognized a simple command.
350
command or some other special construct may have been recognized.
352
If a simple command has been recognized, the shell performs
353
the following actions:
354
.Bl -enum -offset indent
356
Leading words of the form
358
are stripped off and assigned to the environment of the simple command.
359
Redirection operators and their arguments (as described below) are
360
stripped off and saved for processing.
362
The remaining words are expanded as described in
365
and the first remaining word is considered the command name and the
367
The remaining words are considered the arguments of the command.
368
If no command name resulted, then the
370
variable assignments recognized in item 1 affect the current shell.
372
Redirections are performed as described in the next section.
375
Redirections are used to change where a command reads its input or sends
377
In general, redirections open, close, or duplicate an
378
existing reference to a file.
379
The overall format used for redirection is:
381
.Dl [n] Va redir-op Ar file
385
is one of the redirection operators mentioned previously.
386
Following is a list of the possible redirections.
389
is an optional number, as in
393
that refers to a file descriptor.
394
.Bl -tag -width aaabsfiles -offset indent
395
.It [n] Ns \*[Gt] file
396
Redirect standard output (or n) to file.
397
.It [n] Ns \*[Gt]| file
398
Same, but override the
401
.It [n] Ns \*[Gt]\*[Gt] file
402
Append standard output (or n) to file.
403
.It [n] Ns \*[Lt] file
404
Redirect standard input (or n) from file.
405
.It [n1] Ns \*[Lt]& Ns n2
406
Duplicate standard input (or n1) from file descriptor n2.
408
Close standard input (or n).
409
.It [n1] Ns \*[Gt]& Ns n2
410
Duplicate standard output (or n1) to n2.
412
Close standard output (or n).
413
.It [n] Ns \*[Lt]\*[Gt] file
414
Open file for reading and writing on standard input (or n).
417
The following redirection is often called a
419
.Bl -item -offset indent
421
.Li [n]\*[Lt]\*[Lt] delimiter
422
.Dl here-doc-text ...
426
All the text on successive lines up to the delimiter is saved away and
427
made available to the command on standard input, or file descriptor n if
429
If the delimiter as specified on the initial line is
430
quoted, then the here-doc-text is treated literally, otherwise the text is
431
subjected to parameter expansion, command substitution, and arithmetic
432
expansion (as described in the section on
438
then leading tabs in the here-doc-text are stripped.
439
.Ss Search and Execution
440
There are three types of commands: shell functions, builtin commands, and
441
normal programs -- and the command is searched for (by name) in that order.
442
They each are executed in a different way.
444
When a shell function is executed, all of the shell positional parameters
445
(except $0, which remains unchanged) are set to the arguments of the shell
447
The variables which are explicitly placed in the environment of
448
the command (by placing assignments to them before the function name) are
449
made local to the function and are set to the values given.
450
Then the command given in the function definition is executed.
451
The positional parameters are restored to their original values
452
when the command completes.
453
This all occurs within the current shell.
455
Shell builtins are executed internally to the shell, without spawning a
458
Otherwise, if the command name doesn't match a function or builtin, the
459
command is searched for as a normal program in the file system (as
460
described in the next section).
461
When a normal program is executed, the shell runs the program,
462
passing the arguments and the environment to the program.
463
If the program is not a normal executable file (i.e., if it does
464
not begin with the "magic number" whose
466
representation is "#!", so
470
then) the shell will interpret the program in a subshell.
471
The child shell will reinitialize itself in this case,
472
so that the effect will be as if a
473
new shell had been invoked to handle the ad-hoc shell script, except that
474
the location of hashed commands located in the parent shell will be
475
remembered by the child.
477
Note that previous versions of this document and the source code itself
478
misleadingly and sporadically refer to a shell script without a magic
479
number as a "shell procedure".
481
When locating a command, the shell first looks to see if it has a shell
482
function by that name.
483
Then it looks for a builtin command by that name.
484
If a builtin command is not found, one of two things happen:
487
Command names containing a slash are simply executed without performing
490
The shell searches each entry in
492
in turn for the command.
495
variable should be a series of entries separated by colons.
496
Each entry consists of a directory name.
497
The current directory may be indicated
498
implicitly by an empty directory name, or explicitly by a single period.
500
.Ss Command Exit Status
501
Each command has an exit status that can influence the behaviour
502
of other shell commands.
503
The paradigm is that a command exits
504
with zero for normal or success, and non-zero for failure,
505
error, or a false indication.
506
The man page for each command
507
should indicate the various exit codes and what they mean.
508
Additionally, the builtin commands return exit codes, as does
509
an executed shell function.
511
If a command consists entirely of variable assignments then the
512
exit status of the command is that of the last command substitution
515
Complex commands are combinations of simple commands with control
516
operators or reserved words, together creating a larger complex command.
517
More generally, a command is one of the following:
524
list or compound-list
531
Unless otherwise stated, the exit status of a command is that of the last
532
simple command executed by the command.
534
A pipeline is a sequence of one or more commands separated
535
by the control operator |.
536
The standard output of all but
537
the last command is connected to the standard input
539
The standard output of the last
540
command is inherited from the shell, as usual.
542
The format for a pipeline is:
544
.Dl [!] command1 [ | command2 ...]
546
The standard output of command1 is connected to the standard input of
548
The standard input, standard output, or both of a command is
549
considered to be assigned by the pipeline before any redirection specified
550
by redirection operators that are part of the command.
552
If the pipeline is not in the background (discussed later), the shell
553
waits for all commands to complete.
555
If the reserved word ! does not precede the pipeline, the exit status is
556
the exit status of the last command specified in the pipeline.
557
Otherwise, the exit status is the logical NOT of the exit status of the
559
That is, if the last command returns zero, the exit status
560
is 1; if the last command returns greater than zero, the exit status is
563
Because pipeline assignment of standard input or standard output or both
564
takes place before redirection, it can be modified by redirection.
567
.Dl $ command1 2\*[Gt]&1 | command2
569
sends both the standard output and standard error of command1
570
to the standard input of command2.
574
terminator causes the preceding AND-OR-list (described
575
next) to be executed sequentially; a & causes asynchronous execution of
576
the preceding AND-OR-list.
578
Note that unlike some other shells, each process in the pipeline is a
579
child of the invoking shell (unless it is a shell builtin, in which case
580
it executes in the current shell -- but any effect it has on the
581
environment is wiped).
582
.Ss Background Commands -- &
583
If a command is terminated by the control operator ampersand (&), the
584
shell executes the command asynchronously -- that is, the shell does not
585
wait for the command to finish before executing the next command.
587
The format for running a command in background is:
589
.Dl command1 & [command2 & ...]
591
If the shell is not interactive, the standard input of an asynchronous
594
.Ss Lists -- Generally Speaking
595
A list is a sequence of zero or more commands separated by newlines,
596
semicolons, or ampersands, and optionally terminated by one of these three
598
The commands in a list are executed in the order they are written.
599
If command is followed by an ampersand, the shell starts the
600
command and immediately proceed onto the next command; otherwise it waits
601
for the command to terminate before proceeding to the next one.
602
.Ss Short-Circuit List Operators
606
are AND-OR list operators.
608
executes the first command, and then executes the second command iff the
609
exit status of the first command is zero.
611
is similar, but executes the second command iff the exit status of the first
616
both have the same priority.
617
.Ss Flow-Control Constructs -- if, while, for, case
618
The syntax of the if command is
619
.Bd -literal -offset indent
628
The syntax of the while command is
629
.Bd -literal -offset indent
635
The two lists are executed repeatedly while the exit status of the
637
The until command is similar, but has the word
638
until in place of while, which causes it to
639
repeat until the exit status of the first list is zero.
641
The syntax of the for command is
642
.Bd -literal -offset indent
643
for variable in word ...
648
The words are expanded, and then the list is executed repeatedly with the
649
variable set to each word in turn.
650
do and done may be replaced with
655
The syntax of the break and continue command is
656
.Bd -literal -offset indent
661
Break terminates the num innermost for or while loops.
662
Continue continues with the next iteration of the innermost loop.
663
These are implemented as builtin commands.
665
The syntax of the case command is
666
.Bd -literal -offset indent
673
The pattern can actually be one or more patterns (see
675
described later), separated by
678
.Ss Grouping Commands Together
679
Commands may be grouped by writing either
687
The first of these executes the commands in a subshell.
688
Builtin commands grouped into a (list) will not affect the current shell.
689
The second form does not fork another shell so is slightly more efficient.
690
Grouping commands together this way allows you to redirect
691
their output as though they were one program:
693
.Bd -literal -offset indent
694
{ printf \*q hello \*q ; printf \*q world\\n" ; } \*[Gt] greeting
699
must follow a control operator (here,
701
so that it is recognized as a reserved word and not as another command argument.
703
The syntax of a function definition is
707
A function definition is an executable statement; when executed it
708
installs a function named name and returns an exit status of zero.
709
The command is normally a list enclosed between
714
Variables may be declared to be local to a function by using a local
716
This should appear as the first statement of a function, and the syntax is
718
.Dl local [ variable | - ] ...
720
Local is implemented as a builtin command.
722
When a variable is made local, it inherits the initial value and exported
723
and readonly flags from the variable with the same name in the surrounding
724
scope, if there is one.
725
Otherwise, the variable is initially unset.
726
The shell uses dynamic scoping, so that if you make the variable x local to
727
function f, which then calls function g, references to the variable x made
728
inside g will refer to the variable x declared inside f, not to the global
731
The only special parameter that can be made local is
735
local any shell options that are changed via the set command inside the
736
function to be restored to their original values when the function
739
The syntax of the return command is
741
.Dl return [ exitstatus ]
743
It terminates the currently executing function.
744
Return is implemented as a builtin command.
745
.Ss Variables and Parameters
746
The shell maintains a set of parameters.
747
A parameter denoted by a name is called a variable.
748
When starting up, the shell turns all the environment
749
variables into shell variables.
750
New variables can be set using the form
754
Variables set by the user must have a name consisting solely of
755
alphabetics, numerics, and underscores - the first of which must not be
757
A parameter can also be denoted by a number or a special
758
character as explained below.
759
.Ss Positional Parameters
760
A positional parameter is a parameter denoted by a number (n \*[Gt] 0).
761
The shell sets these initially to the values of its command line arguments
762
that follow the name of the shell script.
765
builtin can also be used to set or reset them.
766
.Ss Special Parameters
767
A special parameter is a parameter denoted by one of the following special
769
The value of the parameter is listed next to its character.
770
.Bl -tag -width thinhyphena
772
Expands to the positional parameters, starting from one.
774
expansion occurs within a double-quoted string it expands to a single
775
field with the value of each parameter separated by the first character of
784
Expands to the positional parameters, starting from one.
785
When the expansion occurs within double-quotes, each positional
786
parameter expands as a separate argument.
787
If there are no positional parameters, the
788
expansion of @ generates zero arguments, even when @ is
790
What this basically means, for example, is
801
.Dl \*q abc \*q \ \*q def\ ghi \*q
804
Expands to the number of positional parameters.
806
Expands to the exit status of the most recent pipeline.
808
Expands to the current option flags (the single-letter
809
option names concatenated into a string) as specified on
810
invocation, by the set builtin command, or implicitly
813
Expands to the process ID of the invoked shell.
814
A subshell retains the same value of $ as its parent.
816
Expands to the process ID of the most recent background
817
command executed from the current shell.
818
For a pipeline, the process ID is that of the last command in the pipeline.
820
Expands to the name of the shell or shell script.
823
This clause describes the various expansions that are performed on words.
824
Not all expansions are performed on every word, as explained later.
826
Tilde expansions, parameter expansions, command substitutions, arithmetic
827
expansions, and quote removals that occur within a single word expand to a
829
It is only field splitting or pathname expansion that can
830
create multiple fields from a single word.
831
The single exception to this
832
rule is the expansion of the special parameter @ within double-quotes, as
835
The order of word expansion is:
838
Tilde Expansion, Parameter Expansion, Command Substitution,
839
Arithmetic Expansion (these all occur at the same time).
841
Field Splitting is performed on fields
842
generated by step (1) unless the
846
Pathname Expansion (unless set
853
The $ character is used to introduce parameter expansion, command
854
substitution, or arithmetic evaluation.
855
.Ss Tilde Expansion (substituting a user's home directory)
856
A word beginning with an unquoted tilde character (~) is
857
subjected to tilde expansion.
858
All the characters up to
859
a slash (/) or the end of the word are treated as a username
860
and are replaced with the user's home directory.
861
If the username is missing (as in
863
the tilde is replaced with the value of the
865
variable (the current user's home directory).
866
.Ss Parameter Expansion
867
The format for parameter expansion is as follows:
871
where expression consists of all characters until the matching
875
escaped by a backslash or within a quoted string, and characters in
876
embedded arithmetic expansions, command substitutions, and variable
877
expansions, are not examined in determining the matching
880
The simplest form for parameter expansion is:
884
The value, if any, of parameter is substituted.
886
The parameter name or symbol can be enclosed in braces, which are
887
optional except for positional parameters with more than one digit or
888
when parameter is followed by a character that could be interpreted as
890
If a parameter expansion occurs inside double-quotes:
893
Pathname expansion is not performed on the results of the expansion.
895
Field splitting is not performed on the results of the
896
expansion, with the exception of @.
899
In addition, a parameter expansion can be modified by using one of the
901
.Bl -tag -width aaparameterwordaaaaa
902
.It ${parameter:-word}
904
If parameter is unset or null, the expansion of word
905
is substituted; otherwise, the value of parameter is substituted.
906
.It ${parameter:=word}
907
Assign Default Values.
908
If parameter is unset or null, the expansion of
909
word is assigned to parameter.
910
In all cases, the final value of parameter is substituted.
911
Only variables, not positional parameters or special
912
parameters, can be assigned in this way.
913
.It ${parameter:?[word]}
914
Indicate Error if Null or Unset.
915
If parameter is unset or null, the
916
expansion of word (or a message indicating it is unset if word is omitted)
917
is written to standard error and the shell exits with a nonzero exit status.
918
Otherwise, the value of parameter is substituted.
919
An interactive shell need not exit.
920
.It ${parameter:+word}
921
Use Alternative Value.
922
If parameter is unset or null, null is
923
substituted; otherwise, the expansion of word is substituted.
926
In the parameter expansions shown previously, use of the colon in the
927
format results in a test for a parameter that is unset or null; omission
928
of the colon results in a test for a parameter that is only unset.
929
.Bl -tag -width aaparameterwordaaaaa
932
The length in characters of the value of parameter.
935
The following four varieties of parameter expansion provide for substring
937
In each case, pattern matching notation (see
938
.Sx Shell Patterns ) ,
939
rather than regular expression notation, is used to evaluate the patterns.
940
If parameter is * or @, the result of the expansion is unspecified.
941
Enclosing the full parameter expansion string in double-quotes does not
942
cause the following four varieties of pattern characters to be quoted,
943
whereas quoting characters within the braces has this effect.
944
.Bl -tag -width aaparameterwordaaaaa
945
.It ${parameter%word}
946
Remove Smallest Suffix Pattern.
947
The word is expanded to produce a pattern.
948
The parameter expansion then results in parameter, with the
949
smallest portion of the suffix matched by the pattern deleted.
950
.It ${parameter%%word}
951
Remove Largest Suffix Pattern.
952
The word is expanded to produce a pattern.
953
The parameter expansion then results in parameter, with the largest
954
portion of the suffix matched by the pattern deleted.
955
.It ${parameter#word}
956
Remove Smallest Prefix Pattern.
957
The word is expanded to produce a pattern.
958
The parameter expansion then results in parameter, with the
959
smallest portion of the prefix matched by the pattern deleted.
960
.It ${parameter##word}
961
Remove Largest Prefix Pattern.
962
The word is expanded to produce a pattern.
963
The parameter expansion then results in parameter, with the largest
964
portion of the prefix matched by the pattern deleted.
966
.Ss Command Substitution
967
Command substitution allows the output of a command to be substituted in
968
place of the command name itself.
969
Command substitution occurs when the command is enclosed as follows:
981
The shell expands the command substitution by executing command in a
982
subshell environment and replacing the command substitution with the
983
standard output of the command, removing sequences of one or more
985
at the end of the substitution.
989
the end of the output are not removed; however, during field splitting,
990
they may be translated into
992
depending on the value of
994
and quoting that is in effect.)
995
.Ss Arithmetic Expansion
996
Arithmetic expansion provides a mechanism for evaluating an arithmetic
997
expression and substituting its value.
998
The format for arithmetic expansion is as follows:
1002
The expression is treated as if it were in double-quotes, except
1003
that a double-quote inside the expression is not treated specially.
1004
The shell expands all tokens in the expression for parameter expansion,
1005
command substitution, and quote removal.
1007
Next, the shell treats this as an arithmetic expression and
1008
substitutes the value of the expression.
1009
.Ss White Space Splitting (Field Splitting)
1010
After parameter expansion, command substitution, and
1011
arithmetic expansion the shell scans the results of
1012
expansions and substitutions that did not occur in double-quotes for
1013
field splitting and multiple fields can result.
1015
The shell treats each character of the
1017
as a delimiter and uses the delimiters to split the results of parameter
1018
expansion and command substitution into fields.
1019
.Ss Pathname Expansion (File Name Generation)
1022
flag is set, file name generation is performed after word splitting is
1024
Each word is viewed as a series of patterns, separated by slashes.
1025
The process of expansion replaces the word with the names of all
1026
existing files whose names can be formed by replacing each pattern with a
1027
string that matches the specified pattern.
1028
There are two restrictions on
1029
this: first, a pattern cannot match a string containing a slash, and
1030
second, a pattern cannot match a string starting with a period unless the
1031
first character of the pattern is a period.
1032
The next section describes the
1033
patterns used for both Pathname Expansion and the
1037
A pattern consists of normal characters, which match themselves,
1038
and meta-characters.
1039
The meta-characters are
1045
These characters lose their special meanings if they are quoted.
1046
When command or variable substitution is performed
1047
and the dollar sign or back quotes are not double quoted,
1048
the value of the variable or the output of
1049
the command is scanned for these characters and they are turned into
1054
matches any string of characters.
1055
A question mark matches any single character.
1058
introduces a character class.
1059
The end of the character class is indicated by a
1067
rather than introducing a character class.
1068
A character class matches any of the characters between the square brackets.
1069
A range of characters may be specified using a minus sign.
1070
The character class may be complemented
1071
by making an exclamation point the first character of the character class.
1075
in a character class, make it the first character listed (after the
1078
To include a minus sign, make it the first or last character listed.
1080
This section lists the builtin commands which are builtin because they
1081
need to perform some operation that can't be performed by a separate
1083
In addition to these, there are several other commands that may
1084
be builtin for efficiency (e.g.
1092
A null command that returns a 0 (true) exit value.
1094
The commands in the specified file are read and executed by the shell.
1095
.It alias Op Ar name Ns Op Ar "=string ..."
1098
is specified, the shell defines the alias
1104
is specified, the value of the alias
1107
With no arguments, the
1110
names and values of all defined aliases (see
1112
.It bg [ Ar job ] ...
1113
Continue the specified jobs (or the current job if no
1114
jobs are given) in the background.
1122
Execute the specified command but ignore shell functions when searching
1124
(This is useful when you
1125
have a shell function with the same name as a builtin command.)
1128
search for command using a
1130
that guarantees to find all the standard utilities.
1132
Do not execute the command but
1133
search for the command and print the resolution of the
1135
This is the same as the type builtin.
1137
Do not execute the command but
1138
search for the command and print the absolute pathname
1139
of utilities, the name for builtins or the expansion of aliases.
1145
Switch to the specified directory (default
1149
appears in the environment of the
1151
command or the shell variable
1153
is set and the directory name does not begin with a slash, then the
1154
directories listed in
1156
will be searched for the specified directory.
1159
is the same as that of
1161
If a single dash is specified as the argument, it will be replaced by the
1166
command will print out the name of the
1167
directory that it actually switched to if this is different from the name
1169
These may be different either because the
1171
mechanism was used or because the argument is a single dash.
1174
option causes the physical directory structure to be used, that is, all
1175
symbolic links are resolved to their respective values. The
1177
option turns off the effect of any preceding
1183
Print the arguments on the standard output, separated by spaces.
1186
option is present, a newline is output following the arguments.
1188
If any of the following sequences of characters is encountered during
1189
output, the sequence is not output. Instead, the specified action is
1191
.Bl -tag -width indent
1193
A backspace character is output.
1195
Subsequent output is suppressed. This is normally used at the end of the
1196
last argument to suppress the trailing newline that
1198
would otherwise output.
1202
Output a newline character.
1204
Output a carriage return.
1206
Output a (horizontal) tab character.
1208
Output a vertical tab.
1209
.It Li \e0 Ns Ar digits
1210
Output the character whose value is given by zero to three octal digits.
1211
If there are zero digits, a nul character is output.
1216
All other backslash sequences elicit undefined behaviour.
1217
.It eval Ar string ...
1218
Concatenate all the arguments with spaces.
1219
Then re-parse and execute the command.
1220
.It exec Op Ar command arg ...
1221
Unless command is omitted, the shell process is replaced with the
1222
specified program (which must be a real program, not a shell builtin or
1224
Any redirections on the
1226
command are marked as permanent, so that they are not undone when the
1229
.It exit Op Ar exitstatus
1230
Terminate the shell process.
1233
is given it is used as the exit status of the shell; otherwise the
1234
exit status of the preceding command is used.
1235
.It export Ar name ...
1237
The specified names are exported so that they will appear in the
1238
environment of subsequent commands.
1239
The only way to un-export a variable is to unset it.
1240
The shell allows the value of a variable to be set at the
1241
same time it is exported by writing
1243
.Dl export name=value
1245
With no arguments the export command lists the names of all exported variables.
1248
option specified the output will be formatted suitably for non-interactive use.
1249
.It Xo fc Op Fl e Ar editor
1250
.Op Ar first Op Ar last
1254
.Op Ar first Op Ar last
1256
.It Xo fc Fl s Op Ar old=new
1261
builtin lists, or edits and re-executes, commands previously entered
1262
to an interactive shell.
1265
Use the editor named by editor to edit the commands.
1266
The editor string is a command name, subject to search via the
1271
variable is used as a default when
1276
is null or unset, the value of the
1283
is used as the editor.
1285
List the commands rather than invoking an editor on them.
1286
The commands are written in the sequence indicated by
1287
the first and last operands, as affected by
1289
with each command preceded by the command number.
1291
Suppress command numbers when listing with -l.
1293
Reverse the order of the commands listed (with
1295
or edited (with neither
1300
Re-execute the command without invoking an editor.
1303
Select the commands to list or edit.
1304
The number of previous commands that
1305
can be accessed are determined by the value of the
1308
The value of first or last or both are one of the following:
1311
A positive number representing a command number; command numbers can be
1316
A negative decimal number representing the command that was executed
1317
number of commands previously.
1318
For example, \-1 is the immediately previous command.
1321
A string indicating the most recently entered command that begins with
1323
If the old=new operand is not also specified with
1325
the string form of the first operand cannot contain an embedded equal sign.
1328
The following environment variables affect the execution of fc:
1329
.Bl -tag -width HISTSIZE
1331
Name of the editor to use.
1333
The number of previous commands that are accessible.
1336
Move the specified job or the current job to the foreground.
1337
.It getopts Ar optstring var
1341
command, not to be confused with the
1346
The first argument should be a series of letters, each of which may be
1347
optionally followed by a colon to indicate that the option requires an
1349
The variable specified is set to the parsed option.
1353
command deprecates the older
1355
utility due to its handling of arguments containing whitespace.
1359
builtin may be used to obtain options and their arguments
1360
from a list of parameters.
1363
places the value of the next option from the option string in the list in
1364
the shell variable specified by
1366
and its index in the shell variable
1368
When the shell is invoked,
1370
is initialized to 1.
1371
For each option that requires an argument, the
1373
builtin will place it in the shell variable
1375
If an option is not allowed for in the
1382
is a string of recognized option letters (see
1384
If a letter is followed by a colon, the option is expected to have an
1385
argument which may or may not be separated from it by white space.
1386
If an option character is not found where expected,
1388
will set the variable
1395
and write output to standard error.
1396
By specifying a colon as the first character of
1398
all errors will be ignored.
1400
A nonzero value is returned when the last option is reached.
1401
If there are no remaining arguments,
1405
to the special option,
1407
otherwise, it will set
1412
The following code fragment shows how one might process the arguments
1413
for a command that can take the options
1419
which requires an argument.
1421
.Bd -literal -offset indent
1422
while getopts abc: f
1427
\\?) echo $USAGE; exit 1;;
1430
shift `expr $OPTIND - 1`
1433
This code will accept any of the following as equivalent:
1435
.Bd -literal -offset indent
1436
cmd \-acarg file file
1437
cmd \-a \-c arg file file
1438
cmd \-carg -a file file
1439
cmd \-a \-carg \-\- file file
1441
.It hash Fl rv Ar command ...
1442
The shell maintains a hash table which remembers the
1443
locations of commands.
1444
With no arguments whatsoever,
1447
command prints out the contents of this table.
1448
Entries which have not been looked at since the last
1450
command are marked with an asterisk; it is possible for these entries
1455
command removes the specified commands from the hash table (unless
1456
they are functions) and then locates them.
1459
option, hash prints the locations of the commands as it finds them.
1462
option causes the hash command to delete all the entries in the hash table
1463
except for functions.
1465
builtin command remembers what the current directory
1466
is rather than recomputing it each time.
1467
This makes it faster.
1468
However, if the current directory is renamed, the builtin version of
1470
will continue to print the old name for the directory.
1473
option causes the physical value of the current working directory to be shown,
1474
that is, all symbolic links are resolved to their respective values. The
1476
option turns off the effect of any preceding
1479
.It Xo read Op Fl p Ar prompt
1484
The prompt is printed if the
1486
option is specified and the standard input is a terminal.
1487
Then a line is read from the standard input.
1488
The trailing newline is deleted from the
1489
line and the line is split as described in the section on word splitting
1490
above, and the pieces are assigned to the variables in order.
1491
At least one variable must be specified.
1492
If there are more pieces than variables, the remaining pieces
1493
(along with the characters in
1495
that separated them) are assigned to the last variable.
1496
If there are more variables than pieces,
1497
the remaining variables are assigned the null string.
1500
builtin will indicate success unless EOF is encountered on input, in
1501
which case failure is returned.
1503
By default, unless the
1505
option is specified, the backslash
1507
acts as an escape character, causing the following character to be treated
1509
If a backslash is followed by a newline, the backslash and the
1510
newline will be deleted.
1511
.It readonly Ar name ...
1513
The specified names are marked as read only, so that they cannot be
1514
subsequently modified or unset.
1515
The shell allows the value of a variable
1516
to be set at the same time it is marked read only by writing
1518
.Dl readonly name=value
1520
With no arguments the readonly command lists the names of all read only
1524
option specified the output will be formatted suitably for non-interactive use.
1526
.It Xo printf Ar format
1527
.Op Ar arguments ...
1530
formats and prints its arguments, after the first, under control
1535
is a character string which contains three types of objects: plain characters,
1536
which are simply copied to standard output, character escape sequences which
1537
are converted and copied to the standard output, and format specifications,
1538
each of which causes printing of the next successive
1543
after the first are treated as strings if the corresponding format is
1549
otherwise it is evaluated as a C constant, with the following extensions:
1551
.Bl -bullet -offset indent -compact
1553
A leading plus or minus sign is allowed.
1555
If the leading character is a single or double quote, the value is the
1557
code of the next character.
1560
The format string is reused as often as necessary to satisfy the
1562
Any extra format specifications are evaluated with zero or the null
1565
Character escape sequences are in backslash notation as defined in
1567
The characters and their meanings are as follows:
1568
.Bl -tag -width Ds -offset indent
1570
Write a \*[Lt]bell\*[Gt] character.
1572
Write a \*[Lt]backspace\*[Gt] character.
1574
Write a \*[Lt]form-feed\*[Gt] character.
1576
Write a \*[Lt]new-line\*[Gt] character.
1578
Write a \*[Lt]carriage return\*[Gt] character.
1580
Write a \*[Lt]tab\*[Gt] character.
1582
Write a \*[Lt]vertical tab\*[Gt] character.
1584
Write a backslash character.
1586
Write an 8\-bit character whose
1588
value is the 1\-, 2\-, or 3\-digit
1593
Each format specification is introduced by the percent character
1595
The remainder of the format specification includes,
1596
in the following order:
1598
.It "Zero or more of the following flags:"
1602
specifying that the value should be printed in an ``alternative form''.
1609
formats, this option has no effect.
1612
format the precision of the number is increased to force the first
1613
character of the output string to a zero.
1617
format, a non-zero result has the string
1628
formats, the result will always contain a decimal point, even if no
1629
digits follow the point (normally, a decimal point only appears in the
1630
results of those formats if a digit follows the decimal point).
1635
formats, trailing zeros are not removed from the result as they
1638
A minus sign `\-' which specifies
1640
of the output in the indicated field;
1642
A `+' character specifying that there should always be
1643
a sign placed before the number when using signed formats.
1645
A space specifying that a blank should be left before a positive number
1646
for a signed format.
1647
A `+' overrides a space if both are used;
1649
A zero `0' character indicating that zero-padding should be used
1650
rather than blank-padding.
1651
A `\-' overrides a `0' if both are used;
1654
An optional digit string specifying a
1656
if the output string has fewer characters than the field width it will
1657
be blank-padded on the left (or right, if the left-adjustment indicator
1658
has been given) to make up the field width (note that a leading zero
1659
is a flag, but an embedded zero is part of a field width);
1663
followed by an optional digit string giving a
1665
which specifies the number of digits to appear after the decimal point,
1670
formats, or the maximum number of characters to be printed
1677
formats); if the digit string is missing, the precision is treated
1680
A character which indicates the type of format to use (one of
1681
.Cm diouxXfwEgGbcs ) .
1684
A field width or precision may be
1686
instead of a digit string.
1689
supplies the field width or precision.
1691
The format characters and their meanings are:
1696
is printed as a signed decimal (d or i), unsigned octal, unsigned decimal,
1697
or unsigned hexadecimal (X or x), respectively.
1701
is printed in the style
1703
.Pf [\-]ddd Cm \&. No ddd
1705
where the number of d's
1706
after the decimal point is equal to the precision specification for
1708
If the precision is missing, 6 digits are given; if the precision
1709
is explicitly 0, no digits and no decimal point are printed.
1713
is printed in the style
1715
.Pf [\-]d Cm \&. No ddd Cm e No \\*(Pmdd
1718
is one digit before the decimal point and the number after is equal to
1719
the precision specification for the argument; when the precision is
1720
missing, 6 digits are produced.
1721
An upper-case E is used for an `E' format.
1730
whichever gives full precision in minimum space.
1732
Characters from the string
1734
are printed with backslash-escape sequences expanded.
1736
The following additional backslash-escape sequences are supported:
1741
to ignore any remaining characters in the string operand containing it,
1742
any remaining string operands, and any additional characters in
1744
.It Cm \e0 Ns Ar num
1745
Write an 8\-bit character whose
1747
value is the 1\-, 2\-, or 3\-digit
1752
The first character of
1756
Characters from the string
1758
are printed until the end is reached or until the number of characters
1759
indicated by the precision specification is reached; if the
1760
precision is omitted, all characters in the string are printed.
1762
Print a `%'; no argument is used.
1765
In no case does a non-existent or small field width cause truncation of
1766
a field; padding takes place only if the specified field width exceeds
1770
.Fl options | Cm +options | Cm -- }
1775
command performs three different functions.
1777
With no arguments, it lists the values of all shell variables.
1779
If options are given, it sets the specified option
1780
flags, or clears them as described in the section called
1781
.Sx Argument List Processing .
1783
The third use of the set command is to set the values of the shell's
1784
positional parameters to the specified args.
1785
To change the positional
1786
parameters without changing any options, use
1788
as the first argument to set.
1789
If no args are present, the set command
1790
will clear all the positional parameters (equivalent to executing
1793
Shift the positional parameters n times.
1804
and so on, decreasing
1808
If n is greater than the number of positional parameters,
1810
will issue an error message, and exit with return status 2.
1811
.It test Ar expression
1812
.It \&[ Ar expression Cm ]
1815
utility evaluates the expression and, if it evaluates
1816
to true, returns a zero (true) exit status; otherwise
1817
it returns 1 (false).
1818
If there is no expression, test also
1821
All operators and flags are separate arguments to the
1825
The following primaries are used to construct expression:
1830
exists and is a block special
1835
exists and is a character
1840
exists and is a directory.
1844
exists (regardless of type).
1848
exists and is a regular file.
1852
exists and its set group ID flag
1857
exists and is a symbolic link.
1861
exists and its sticky bit is set.
1863
True if the length of
1874
exists and is readable.
1878
exists and has a size greater
1880
.It Fl t Ar file_descriptor
1881
True if the file whose file descriptor number
1884
is open and is associated with a terminal.
1888
exists and its set user ID flag
1893
exists and is writable.
1895
indicates only that the write flag is on.
1896
The file is not writable on a read-only file
1897
system even if this test indicates true.
1901
exists and is executable.
1903
indicates only that the execute flag is on.
1906
is a directory, true indicates that
1910
True if the length of
1916
exists and is a symbolic link.
1917
This operator is retained for compatibility with previous versions of
1919
Do not rely on its existence; use
1925
exists and its owner matches the effective user id of this process.
1929
exists and its group matches the effective group id of this process.
1933
exists and is a socket.
1934
.It Ar file1 Fl nt Ar file2
1937
exists and is newer than
1939
.It Ar file1 Fl ot Ar file2
1942
exists and is older than
1944
.It Ar file1 Fl ef Ar file2
1949
exist and refer to the same file.
1955
.It Ar \&s\&1 Cm \&= Ar \&s\&2
1961
.It Ar \&s\&1 Cm \&!= Ar \&s\&2
1967
.It Ar \&s\&1 Cm \&\*[Lt] Ar \&s\&2
1972
based on the ASCII value of their characters.
1973
.It Ar \&s\&1 Cm \&\*[Gt] Ar \&s\&2
1978
based on the ASCII value of their characters.
1979
.It Ar \&n\&1 Fl \&eq Ar \&n\&2
1980
True if the integers
1986
.It Ar \&n\&1 Fl \&ne Ar \&n\&2
1987
True if the integers
1992
algebraically equal.
1993
.It Ar \&n\&1 Fl \> Ar \&n\&2
1997
greater than the integer
1999
.It Ar \&n\&1 Fl \&ge Ar \&n\&2
2003
greater than or equal to the integer
2005
.It Ar \&n\&1 Fl \< Ar \&n\&2
2008
is algebraically less
2011
.It Ar \&n\&1 Fl \&le Ar \&n\&2
2014
is algebraically less
2015
than or equal to the integer
2019
These primaries can be combined with the following operators:
2021
.It Cm \&! Ar expression
2025
.It Ar expression1 Fl a Ar expression2
2031
.It Ar expression1 Fl o Ar expression2
2037
.It Cm \&( Ns Ar expression Ns Cm \&)
2038
True if expression is true.
2043
operator has higher precedence than the
2047
Print the accumulated user and system times for the shell and for processes
2048
run from the shell. The return status is 0.
2050
.Op Ar action Ar signal ...
2052
Cause the shell to parse and execute action when any of the specified
2053
signals are received.
2054
The signals are specified by signal number or as the name of the signal.
2059
the action is executed when the shell exits.
2061
may be null, which cause the specified signals to be ignored.
2064
omitted or set to `-' the specified signals are set to their default action.
2065
When the shell forks off a subshell, it resets trapped (but not ignored)
2066
signals to the default action.
2069
command has no effect on signals that were
2070
ignored on entry to the shell.
2072
without any arguments cause it to write a list of signals and their
2073
associated action to the standard output in a format that is suitable
2074
as an input to the shell that achieves the same trapping results.
2080
List trapped signals and their corresponding action
2082
.Dl trap '' INT QUIT tstp 30
2084
Ignore signals INT QUIT TSTP USR1
2088
Print date upon receiving signal INT
2089
.It type Op Ar name ...
2090
Interpret each name as a command and print the resolution of the command
2092
Possible resolutions are:
2093
shell keyword, alias, shell builtin,
2094
command, tracked alias and not found.
2095
For aliases the alias expansion is
2096
printed; for commands and tracked aliases the complete pathname of the
2100
.Op Fl a \*(Ba Fl tfdscmlpn Op Ar value
2102
Inquire about or set the hard or soft limits on processes or set new
2104
The choice between hard limit (which no process is allowed to
2105
violate, and which may not be raised once it has been lowered) and soft
2106
limit (which causes processes to be signaled but not necessarily killed,
2107
and which may be raised) is made with these flags:
2110
set or inquire about hard limits
2112
set or inquire about soft limits.
2117
is specified, the soft limit is displayed or both limits are set.
2118
If both are specified, the last one wins.
2122
The limit to be interrogated or set, then, is chosen by specifying
2123
any one of these flags:
2125
show all the current limits
2127
show or set the limit on CPU time (in seconds)
2129
show or set the limit on the largest file that can be created
2130
(in 512-byte blocks)
2132
show or set the limit on the data segment size of a process (in kilobytes)
2134
show or set the limit on the stack size of a process (in kilobytes)
2136
show or set the limit on the largest core dump size that can be produced
2137
(in 512-byte blocks)
2139
show or set the limit on the total physical memory that can be
2140
in use by a process (in kilobytes)
2142
show or set the limit on how much memory a process can lock with
2146
show or set the limit on the number of processes this user can
2149
show or set the limit on the number files a process can have open at once
2152
If none of these is specified, it is the limit on file size that is shown
2154
If value is specified, the limit is set to that number; otherwise
2155
the current limit is displayed.
2157
Limits of an arbitrary process can be displayed or set using the
2161
.It umask Op Ar mask
2162
Set the value of umask (see
2164
to the specified octal value.
2165
If the argument is omitted, the umask value is printed.
2172
is specified, the shell removes that alias.
2175
is specified, all aliases are removed.
2180
The specified variables and functions are unset and unexported.
2185
is specified, the corresponding function or variable is unset, respectively.
2186
If a given name corresponds to both a variable and a function, and no
2187
options are given, only the variable is unset.
2189
Wait for the specified job to complete and return the exit status of the
2190
last process in the job.
2191
If the argument is omitted, wait for all jobs to
2192
complete and the return an exit status of zero.
2194
.Ss Command Line Editing
2197
is being used interactively from a terminal, the current command
2198
and the command history (see
2202
can be edited using vi-mode command-line editing.
2203
This mode uses commands, described below,
2204
similar to a subset of those described in the vi man page.
2207
enables vi-mode editing and place sh into vi insert mode.
2209
enabled, sh can be switched between insert mode and command mode.
2210
The editor is not described in full here, but will be in a later document.
2211
It's similar to vi: typing
2213
will throw you into command VI command mode.
2216
while in command mode will pass the line to the shell.
2218
Errors that are detected by the shell, such as a syntax error, will cause the
2219
shell to exit with a non-zero exit status.
2220
If the shell is not an
2221
interactive shell, the execution of the shell file will be aborted.
2223
the shell will return the exit status of the last command executed, or
2224
if the exit builtin is used with a numeric argument, it will return the
2227
.Bl -tag -width MAILCHECK
2229
Set automatically by
2231
from the user's login directory in the password file
2233
This environment variable also functions as the default argument for the
2236
The default search path for executables.
2237
See the above section
2240
The search path used with the cd builtin.
2242
The name of a mail file, that will be checked for the arrival of new mail.
2246
The frequency in seconds that the shell checks for the arrival of mail
2247
in the files specified by the
2252
If set to 0, the check will occur at each prompt.
2256
separated list of file names, for the shell to check for incoming mail.
2257
This environment setting overrides the
2260
There is a maximum of 10 mailboxes that can be monitored at once.
2262
The primary prompt string, which defaults to
2264
unless you are the superuser, in which case it defaults to
2267
The secondary prompt string, which defaults to
2270
Output before each line when execution trace (set -x) is enabled,
2274
Input Field Separators.
2275
This is normally set to
2281
.Sx White Space Splitting
2282
section for more details.
2284
The default terminal setting for the shell.
2285
This is inherited by
2286
children of the shell, and is used in the history editing modes.
2288
The number of lines in the history buffer for the shell.
2290
The logical value of the current working directory. This is set by the
2294
The previous logical value of the current working directory. This is set by
2299
The process ID of the parent process of the shell.
2302
.Bl -item -width HOMEprofilexxxx
2326
It was, however, unmaintainable so we wrote this one.
2328
Setuid shell scripts should be avoided at all costs, as they are a
2329
significant security risk.
2331
PS1, PS2, and PS4 should be subject to parameter expansion before