summaryrefslogtreecommitdiff
path: root/bin/ksh/sh.1tbl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ksh/sh.1tbl')
-rw-r--r--bin/ksh/sh.1tbl327
1 files changed, 168 insertions, 159 deletions
diff --git a/bin/ksh/sh.1tbl b/bin/ksh/sh.1tbl
index 97ae3b773c5..ec899910111 100644
--- a/bin/ksh/sh.1tbl
+++ b/bin/ksh/sh.1tbl
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sh.1tbl,v 1.10 1999/05/28 12:23:06 aaron Exp $
+.\" $OpenBSD: sh.1tbl,v 1.11 1999/05/30 17:44:56 aaron Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -150,10 +150,10 @@ option of the built-in command
can't be used.
.It
Redirections that create files can't be used (i.e.,
-.Sq > ,
-.Sq >| ,
-.Sq >> ,
-.Sq <> ) .
+.Ql > ,
+.Ql >| ,
+.Ql >> ,
+.Ql <> ) .
.El
.Pp
A shell is
@@ -176,7 +176,7 @@ its effective user ID (group ID) to its real user ID (group ID).
.Pp
If the basename of the name the shell is called with (i.e., argv[0])
starts with
-.Sq \&-
+.Ql -
or if the
.Fl l
option is used,
@@ -216,42 +216,42 @@ The shells begins parsing its input by breaking it into
Words, which are sequences of characters, are delimited by unquoted whitespace
characters (space, tab, and newline) or meta-characters
.Po
-.Sq \&< ,
-.Sq \&> ,
-.Sq \&| ,
-.Sq \&; ,
-.Sq \&( ,
+.Ql < ,
+.Ql > ,
+.Ql | ,
+.Ql \&; ,
+.Ql ( ,
and
-.Sq \&)
+.Ql \&)
.Pc .
Aside from delimiting words, spaces and tabs are ignored, while newlines
usually delimit commands. The meta-charcters are used in building the
following tokens:
-.Sq \&< ,
-.Sq \&<\&& ,
-.Sq \&<\&< ,
-.Sq \&> ,
-.Sq \&>\&& ,
-.Sq \&>\&> ,
+.Ql < ,
+.Ql <& ,
+.Ql << ,
+.Ql > ,
+.Ql >& ,
+.Ql >> ,
etc. are used to specify redirections (see
.Sx Input/output redirection
below);
-.Sq \&|
+.Ql |
is used to create pipelines;
-.Sq \&;
+.Ql \&;
is used to separate commands;
-.Sq \&&
+.Ql &
is used to create asynchronous pipelines;
-.Sq \&&\&&
+.Ql &&
and
-.Sq \&|\&|
+.Ql ||
are used to specify conditional execution;
-.Sq \&;\&;
+.Ql \&;\&;
is used in
.Ic case
statements;
and lastly,
-.Sq \&( .. \&)
+.Ql \&( .. \&)
is used to create subshells.
.Pp
Whitespace and meta-characters can be quoted individually using a backslash
@@ -262,52 +262,52 @@ or single
.Pq Sq \&'
quotes. Note that the following characters are also treated specially by the
shell and must be quoted if they are to represent themselves:
-.Sq \e ,
-.Sq \&" ,
-.Sq \&' ,
-.Sq \&# ,
-.Sq \&$ ,
-.Sq \&` ,
-.Sq \&~ ,
-.Sq \&{ ,
-.Sq \&} ,
-.Sq \&* ,
-.Sq \&? ,
+.Ql \e ,
+.Ql \&" ,
+.Ql ' ,
+.Ql # ,
+.Ql $ ,
+.Ql ` ,
+.Ql ~ ,
+.Ql { ,
+.Ql } ,
+.Ql * ,
+.Ql ? ,
and
-.Sq \&[ .
+.Ql [ .
The first three of these are the above mentioned quoting characters (see
.Sx Quoting
below);
-.Sq \&# ,
+.Ql # ,
if used at the beginning of a word, introduces a comment -- everything after
the
-.Sq \&#
+.Ql #
up to the nearest newline is ignored;
-.Sq \&$
+.Ql $
is used to introduce parameter, command and arithmetic substitutions (see
.Sx Substitution
below);
-.Sq \&`
+.Ql `
introduces an old-style command substitution (see
.Sx Substitution
below);
-.Sq \&~
+.Ql ~
begins a directory expansion (see
.Sx Tilde expansion
below);
-.Sq \&{
+.Ql {
and
-.Sq \&}
+.Ql }
delimit
.Xr csh 1
style alterations (see
.Sx Brace expansion
below);
and finally,
-.Sq \&* ,
-.Sq \&? ,
+.Ql * ,
+.Ql ? ,
and
-.Sq \&[
+.Ql [
are used in file name generation (see
.Sx File name patterns
below).
@@ -351,13 +351,13 @@ assignments is that of the last command substitution performed during the
parameter assignment or 0 is there were no command substitutions.
.Pp
Commands can be chained together using the
-.Sq \&|
+.Ql |
token to form pipelines, in which the standard output of each command but the
last is piped (see
.Xr pipe 2 )
to the standard input of the following command. The exit status of a pipeline
is that of its last command. A pipeline may be prefixed by the
-.Sq \&!
+.Ql !
reversed word which causes the exit status of the pipeline to be logically
complemented: if the original status was 0 the complemented status will be 1;
if the original status was not 0, the complemented status will be 0.
@@ -365,12 +365,12 @@ if the original status was not 0, the complemented status will be 0.
.Em Lists
of commands can be created by separating pipelines by any of the following
tokens:
-.Sq \&&\&& ,
-.Sq \&|\&| ,
-.Sq \&& ,
-.Sq \&|\&& ,
+.Ql && ,
+.Ql || ,
+.Ql & ,
+.Ql |& ,
and
-.Sq \&; .
+.Ql \&; .
The first two are for conditional execution:
.Dq Ar cmd1 No && Ar cmd2
executes
@@ -378,22 +378,22 @@ executes
only if the exit status of
.Ar cmd1
is zero;
-.Sq \&|\&|
+.Ql ||
is the opposite --
.Ar cmd2
is executed only if the exit status of
.Ar cmd1
is non-zero.
-.Sq \&&\&&
+.Ql &&
and
-.Sq \&|\&|
+.Ql ||
have equal precedence which is higher that that of
-.Sq \&& ,
-.Sq \&|\&&
+.Ql & ,
+.Ql |&
and
-.Sq \&; ,
+.Ql \&; ,
which also have equal precedence. The
-.Sq \&&
+.Ql &
token causes the preceding command to be executed asynchronously; that is,
the shell starts the command but does not wait for it to complete (the shell
does keep track of the status of asynchronous commands, see
@@ -407,14 +407,14 @@ ignored and with input redirected from
.Pa /dev/null
(however, redirections specified in the asynchronous command have precedence).
Note that a command must follow the
-.Sq \&&\&&
+.Ql &&
and
-.Sq \&|\&|
+.Ql ||
operators, while it need not follow
-.Sq \&& ,
-.Sq \&|\&&
+.Ql & ,
+.Ql |&
or
-.Sq \&; .
+.Ql \&; .
The exit status of a list is that of the last command executed, with the
exception of asynchronous lists, for which the exit status is 0.
.Pp
@@ -432,7 +432,8 @@ done fi in while {
elif for time then }
.TE
.Pp
-NOTE: Some shells (but not this one) execute control structure commands in a
+.Sy Note:
+Some shells (but not this one) execute control structure commands in a
subshell when one or more of their file descriptors are redirected, so any
environment changes inside them may fail. To be portable, the
.Ic exec
@@ -491,9 +492,9 @@ used in
.Ic case
statements are the same as those used for file name patterns except that the
restrictions regarding
-.Sq \&.
+.Ql \&.
and
-.Sq \&/
+.Ql /
are dropped. Note that any unquoted space before and after a pattern is
stripped; any space with a pattern must be quoted. Both the word and the
patterns are subject to parameter, command and arithmetic substitution as
@@ -540,7 +541,7 @@ if
is never executed, the exit status is zero.
.Ar term
is either a newline or a
-.Sq \&; .
+.Ql \&; .
.It Xo Ic if Ar list Ic then
.Ar list [ Ic elif Ar list Ic then
.Ar list ] Ar ... [ Ic else
@@ -611,42 +612,43 @@ below).
.Ss Quoting
Quoting is used to prevent the shell from treating characters or words
specially. There are three methods of quoting. First,
-.Sq \e
+.Ql \e
quotes the following character, unless it is at the end of a line, in which
case both the
-.Sq \e
+.Ql \e
and the newline are stripped. Second, a single quote
.Pq Sq '
quotes everything up to the next single quote (this may span lines). Third,
a double quote
.Pq Sq \&"
quotes all characters, except
-.Sq \&$ ,
-.Sq \&`
+.Ql $ ,
+.Ql `
and
-.Sq \e ,
+.Ql \e ,
up to the next unquoted double quote.
-.Sq $
+.Ql $
and
-.Sq `
+.Ql `
inside double quotes have their usual meaning (i.e., parameter, command or
arithmetic substitution) except no field splitting is carried out on the
results of double-quoted substitutions. If a
-.Sq \e
+.Ql \e
inside a double-quoted string is followed by
-.Sq \e ,
-.Sq $ ,
-.Sq ` ,
+.Ql \e ,
+.Ql $ ,
+.Ql ` ,
or
-.Sq \&" ,
+.Ql \&" ,
it is replaced by the second character; if it is followed by a newline, both
the
-.Sq \e
+.Ql \e
and the newline are stripped; otherwise, both the
-.Sq \e
+.Ql \e
and the character following are unchanged.
.Pp
-NOTE: See
+.Sy Note:
+See
.Sx POSIX mode
below for a special rule regarding sequences of the form
.Ic \&"...`...\e\&"...`..\&" .
@@ -724,11 +726,15 @@ characters are called
.Dq IFS whitespace .
Sequences of one or more
.Ev IFS
-whitespace characters, in combination with zero or none non-IFS whitespace
+whitespace characters, in combination with zero or no
+.Pf non- Ev IFS
+whitespace
characters delimit a field. As a special case, leading and trailing
.Ev IFS
whitespace is stripped (i.e., no leading or trailing empty field is created by
-it); leading or trailing non-IFS whitespace does create an empty field.
+it); leading or trailing
+.Pf non- Ev IFS
+whitespace does create an empty field.
.Pp
Example: If
.Ev IFS
@@ -780,14 +786,14 @@ substitutions, normal quoting rules are used when
is parsed, however, for the
.Ic ` Ns Ar command Ns Ic `
form, a
-.Sq \e
+.Ql \e
followed by any of
-.Sq $ ,
-.Sq ` ,
+.Ql $ ,
+.Ql ` ,
or
-.Sq \e
+.Ql \e
is stripped (a
-.Sq \e
+.Ql \e
followed by any other character is unchanged). As a special case in command
substitutions, a command of the form
.Ic \&< Ar file
@@ -799,7 +805,7 @@ has the same effect as
.Ic $(cat foo) ,
but it is carried out more efficiently because no process is started).
.Pp
-NOTE:
+.Sy Note:
.Ic $( Ns Ar command Ns Ic \&)
expressions are currently parsed by finding the matching parenthesis,
regardless of quoting. This will hopefully be fixed soon.
@@ -816,7 +822,7 @@ can be accessed using a parameter substitution. A parameter name is either one
of the special single punctuation or digit character parameters described
below, or a letter followed by zero or more letters or digits
.Po
-.Sq _
+.Ql _
counts as a letter
.Pc .
Parameter substitutions take the form
@@ -854,7 +860,7 @@ can be followed by a simple-command, in which case the assignments are in
effect only for the duration of the command (such assignments are also
exported, see below for implications of this). Note that both the parameter
name and the
-.Sq =
+.Ql =
must be unquoted for the shell to recognize a parameter assignment. The fourth
way of setting a parameter is with the
.Ic export ,
@@ -946,7 +952,7 @@ is used instead.
.El
.Pp
In the above modifiers, the
-.Sq \&:
+.Ql \&:
can be omitted, in which case the conditions only depand on
.Ar name
being set (as opposed to set and not
@@ -964,8 +970,8 @@ The following forms of parameter substitution can also be used:
The number of positional parameters if
.Ar name
is
-.Sq \&* ,
-.Sq \&@ ,
+.Ql * ,
+.Ql @ ,
not specified, or the length of the string value of parameter
.Ar name .
.It Xo Ic ${# Ns Ar name Ns
@@ -984,7 +990,7 @@ If
matches the beginning of the value of parameter
.Ar name ,
the matched text is deleted from the result of substitution. A single
-.Sq \&#
+.Ql #
results in the shortest match, two
of them results in the longest match.
.Sm off
@@ -1068,7 +1074,7 @@ Search path for the
built-in command. Works the same way as
.Ev PATH
for those directories not beginning with
-.Sq \&/
+.Ql /
in
.Ic cd
commands. Note that if
@@ -1134,7 +1140,8 @@ and newline. See
.Sx Substitution
above for details.
.Pp
-NOTE: This parameter is not imported from the environment when the shell is
+.Sy Note:
+This parameter is not imported from the environment when the shell is
started.
.It Ev SH_VERSION
The version of shell and the date the version was created (read-only).
@@ -1206,13 +1213,13 @@ files are created in
.Ss Tilde expansion
Tilde expansion, which is done in parallel with parameter substitution, is done
on words starting with an unquoted
-.Sq ~ .
+.Ql ~ .
The characters following the tilde, up to the first
-.Sq / ,
+.Ql / ,
if any, are assumed to be a login name. If the login name is empty,
-.Sq \&+
+.Ql +
or
-.Sq \&- ,
+.Ql - ,
the value of the
.Ev HOME , PWD
or
@@ -1241,9 +1248,9 @@ command may be used to list, change and add to this cache (e.g.,
.Ic alias -d fac=/usr/local/facilities; cd ~fac/bin ) .
.Ss File name patterns
A file name pattern is a word containing one or more unquoted
-.Sq \&?
+.Ql ?
or
-.Sq \&*
+.Ql *
characters or
.Dq [..]
sequences. Once brace expansion has been performed, the shell replaces file
@@ -1258,19 +1265,19 @@ Matches any sequence of characters.
.It Ic \&[ Ns No .. Ns Ic \&]
Matches any of the characters inside the brackets. Ranges of characters can be
specified by separating two characters by a
-.Sq \&-
+.Ql -
(e.g.,
.Dq [a0-9]
matches the letter
.Dq a
or any digit). In order to represent itself, a
-.Sq \&-
+.Ql -
must either be quoted or the first or last character in the character list.
Similarly, a
-.Sq \&]
+.Ql \&]
must be quoted or the first character in the list if it is to represent itself
instead of the end of the list. Also, a
-.Sq \&!
+.Ql !
appearing at the start of the list has special meaning (see below), so to
represent itself it must be quoted or appear later in the list.
.It Ic \&[\&! Ns No .. Ns Ic \&]
@@ -1310,7 +1317,7 @@ If the
.Ic markdirs
option is set, any directories that result from file name generation are marked
with a trailing
-.Sq / .
+.Ql / .
.Pp
The POSIX character classes (i.e.,
.Ic \&[\&: Ns Ar class-name Ns Ic \&:\&]
@@ -1380,9 +1387,9 @@ parameter, command and arithmetic substitutions are performed, along with
backslash
.Pq Sq \e
escapes for
-.Sq \&$ ,
-.Sq ` ,
-.Sq \e ,
+.Ql $ ,
+.Ql ` ,
+.Ql \e ,
and
.Dq \enewline .
If multiple here documents are used on the same command line, they are saved in
@@ -1397,10 +1404,10 @@ Standard input is duplicated from file descriptor
.Ar fd
can be a single digit, indicating the number of an existing file descriptor;
the letter
-.Sq p ,
+.Ql p ,
indicating the file descriptor associated with the output of the current
co-process; or the character
-.Sq \&- ,
+.Ql - ,
indicating standard input is to be closed.
.It Ic \&>\&& Ar fd
Same as
@@ -1755,11 +1762,11 @@ non-POSIX mode, the exit status is that of the last foregrounded job.
.It
.Ic getopts .
In POSIX mode, options must start with a
-.Sq \&- ;
+.Ql - ;
in non-POSIX mode, options can start with either
-.Sq \&-
+.Ql -
or
-.Sq \&+ .
+.Ql + .
.It
Brace expansion (also known as alternation). In POSIX mode, brace expansion is
disabled; in non-POSIX mode, brace expansion is enabled. Note that
@@ -1824,9 +1831,9 @@ in POSIX mode,
in non-POSIX mode.
.It
Test. In POSIX mode, the expression
-.Sq Fl t
+.Ql Fl t
(preceded by some number of
-.Sq Ic \&!
+.Ql Ic \&!
arguments) is always true as it is a non-zero length string; in non-POSIX mode,
it tests if file descriptor 1 is a tty (i.e., the
.Ar fd
@@ -1924,7 +1931,7 @@ as
where
.Ar value
is quoted. If options were preceded with
-.Sq \&+ ,
+.Ql + ,
or a lone \&+ is given on the command line, only
.Ar name
is printed. In addition, if the
@@ -2009,7 +2016,7 @@ is missing, the home directory
is used. If
.Ar dir
is
-.Sq \&- ,
+.Ql - ,
the previous working directory is used (see
.Ev OLDPWD
parameter). If the
@@ -2077,7 +2084,7 @@ defaults to 1.
Prints its arguments (separated by spaces) followed by a newline, to the
standard output. The newline is suppressed if any of the arguments contain the
backslash sequence
-.Sq \ec .
+.Ql \ec .
See the
.Ic print
command below for a list of other backslash sequences that are recognized.
@@ -2170,11 +2177,11 @@ is invoked, it places the next option in the shell parameter
and the index of the next argument to be processed in the shell parameter
.Ev OPTIND .
If the option was introduced with a
-.Sq \&+ ,
+.Ql + ,
the option places in
.Ar name
is prefixed with a
-.Sq \&+ .
+.Ql + .
When an option requires an argument,
.Ic getopts
places it in the shell parameter
@@ -2193,9 +2200,9 @@ When the end of the options is encountered,
.Ic getopts
exits with a non-zero exit status. Options end at the first (non-option
argument) argument that does not start with a
-.Sq \&- ,
+.Ql - ,
or when a
-.Sq \&-\&-
+.Ql --
argument is encountered.
.Pp
Option parsing can be reset by setting
@@ -2260,23 +2267,23 @@ terminated with a newline. The
.Fl n
option suppresses the newline. By default, certain C escapes are translated.
These include
-.Sq \eb ,
-.Sq \ef ,
-.Sq \en ,
-.Sq \er ,
-.Sq \et ,
-.Sq \ev ,
+.Ql \eb ,
+.Ql \ef ,
+.Ql \en ,
+.Ql \er ,
+.Ql \et ,
+.Ql \ev ,
and
-.Sq \e0###
+.Ql \e0###
.Po
-.Sq #
+.Ql #
is an octal digit, of which there may be 0 to 3
.Pc .
-.Sq \ec
+.Ql \ec
is equivalent to using the
.Fl n
option.
-.Sq \e
+.Ql \e
expansion may be inhibited with the
.Fl r
option. The
@@ -2301,7 +2308,7 @@ option is used to emulate, to some degree, the
.Bx
.Xr echo
command, which does not process
-.Sq \e
+.Ql \e
sequences unless the
.Fl e
option is given. As above, the
@@ -2503,10 +2510,10 @@ if
is used).
.It Fl u Ic nounset
Referencing of an unset parameter is treated as an error, unless one of the
-.Sq \&- ,
-.Sq \&+
+.Ql - ,
+.Ql +
or
-.Sq =
+.Ql =
modifiers is used.
.It Fl v Ic verbose
Write shell input to standard error as it is read.
@@ -2516,7 +2523,7 @@ the value of
.Ev PS4 .
.It Fl X Ic markdirs
Mark directories with a trailing
-.Sq /
+.Ql /
during file name generation.
.It Ic bgnice
Background jobs are run with lower priority.
@@ -2571,7 +2578,8 @@ Enable vi-like command line editing (interactive shells only).
No effect. In the original Korn shell, unless
.Ic viraw
was set, the vi command line mode would let the tty driver do the work until
-ESC (^[) was entered.
+.Tn ESC
+(^[) was entered.
.Nm pdksh
is always in viraw mode.
.It Ic vi-esccomplete
@@ -2597,11 +2605,11 @@ will print the long names of all options that are currently on.
.Pp
Remaining arguments, if any, are positional parameters and are assigned, in
order, to the positional parameters (i.e., $1, $2, etc.). If options end with
-.Sq \&-\&-
+.Ql --
and there are no remaining arguments, all positional parameters are cleared. If
no options or arguments are given, the values of all names are printed. For
unknown historical reasons, a lone
-.Sq \&-
+.Ql -
option is treated specially -- it clears both the
.Fl x
and
@@ -2709,7 +2717,7 @@ is set (see
.Ic set
command above for a list of options). As a non-standard extension, if the
option starts with a
-.Sq \&! ,
+.Ql ! ,
the test is negated; the test always fails if
.Ar option
doesn't exist (thus
@@ -2802,17 +2810,18 @@ arguments to
or
.Ic \&[ ... \&]
is less than five; if leading
-.Sq \&!
+.Ql !
arguments can be stripped such that only one argument remains then a string
length test is performed (again, even if the argument is a unary operator); if
leading
-.Sq \&!
+.Ql !
arguments can be stripped such that three arguments remain and the second
argument is a binary operator, then the binary operation is performed (even
if the first argument is a unary operator, including an unstripped
-.Sq \&! ) .
+.Ql ! ) .
.Pp
-NOTE: A common mistake is to use
+.Sy Note:
+A common mistake is to use
.Ic if \&[ $foo = bar \&]
which fails if parameter
.Ic foo
@@ -2821,9 +2830,9 @@ is
or unset, if it has embedded spaces (i.e.,
.Ev IFS
characters), or if it is a unary operator like
-.Sq Ic \&!
+.Ql Ic \&!
or
-.Sq Fl n .
+.Ql Fl n .
Use tests like
.Ic if \&[ \&"X$foo\&" = Xbar \&]
instead.
@@ -2894,10 +2903,10 @@ arguments, parameter attributes are displayed; if no options are used, the
current attributes of all parameters are printed as
.Ic typeset
commands; if an option is given (or
-.Sq \&-
+.Ql -
with no option letter), all parameters and their values with the specified
attributes are printed; if options are introduced with
-.Sq \&+ ,
+.Ql + ,
parameter values are not printed.
.Pp
If
@@ -2919,7 +2928,7 @@ operates on the attributes of functions. As with parameters, if no
.Ar name Ns s
are given, functions are listed with their values (i.e., definitions) unless
options are introduced with
-.Sq \&+ ,
+.Ql + ,
in which case only the function names are reported.
.Bl -tag -width 3n
.It Fl L Ns Ar n
@@ -3261,9 +3270,9 @@ where
is the job number of the job.
.It Ar flag
is the
-.Sq \&+
+.Ql +
or
-.Sq \&-
+.Ql -
character if the job is the
.Ic %\&+ or
.Ic %\&-