Fri Mar 16 11:53:57 2018 UTC ()
Restore some (*roff) comments deleted in previous (partially unshave
the yak) for which the purpose was misunderstood.   But trim one more hair.


(kre)
diff -r1.194 -r1.195 src/bin/sh/sh.1

cvs diff -r1.194 -r1.195 src/bin/sh/sh.1 (expand / switch to unified diff)

--- src/bin/sh/sh.1 2018/03/16 11:19:24 1.194
+++ src/bin/sh/sh.1 2018/03/16 11:53:57 1.195
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: sh.1,v 1.194 2018/03/16 11:19:24 kre Exp $ 1.\" $NetBSD: sh.1,v 1.195 2018/03/16 11:53:57 kre Exp $
2.\" Copyright (c) 1991, 1993 2.\" Copyright (c) 1991, 1993
3.\" The Regents of the University of California. All rights reserved. 3.\" The Regents of the University of California. All rights reserved.
4.\" 4.\"
5.\" This code is derived from software contributed to Berkeley by 5.\" This code is derived from software contributed to Berkeley by
6.\" Kenneth Almquist. 6.\" Kenneth Almquist.
7.\" 7.\"
8.\" Redistribution and use in source and binary forms, with or without 8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions 9.\" modification, are permitted provided that the following conditions
10.\" are met: 10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright 11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer. 12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the 14.\" notice, this list of conditions and the following disclaimer in the
@@ -276,27 +276,27 @@ built-in (described later). @@ -276,27 +276,27 @@ built-in (described later).
276Automatically export any variable to which a value is assigned 276Automatically export any variable to which a value is assigned
277while this flag is set. 277while this flag is set.
278.It Fl b Em notify 278.It Fl b Em notify
279Enable asynchronous notification of background job completion. 279Enable asynchronous notification of background job completion.
280(Not implemented.) 280(Not implemented.)
281.It Fl C Em noclobber 281.It Fl C Em noclobber
282Don't overwrite existing files with 282Don't overwrite existing files with
283.Dq > . 283.Dq > .
284.It Fl c 284.It Fl c
285Read commands from the 285Read commands from the
286.Ar command_string 286.Ar command_string
287operand instead of, or in addition to, from the standard input. 287operand instead of, or in addition to, from the standard input.
288Special parameter 288Special parameter
289.Dv 0 289.Dv 0 \" $0
290will be set from the 290will be set from the
291.Ar command_name 291.Ar command_name
292operand if given, and the positional parameters 292operand if given, and the positional parameters
293.Li ( 1 , 2 , 293.Li ( 1 , 2 ,
294etc.) 294etc.)
295set from the remaining argument operands, if any. 295set from the remaining argument operands, if any.
296.Fl c 296.Fl c
297is only available at invocation, it cannot be 297is only available at invocation, it cannot be
298.Ic set , 298.Ic set ,
299and there is no form using 299and there is no form using
300.Dq Cm \&+ . 300.Dq Cm \&+ .
301.It Fl E Em emacs 301.It Fl E Em emacs
302Enable the built-in emacs style 302Enable the built-in emacs style
@@ -995,27 +995,27 @@ reached before the delimiter is encounte @@ -995,27 +995,27 @@ reached before the delimiter is encounte
995.\" 995.\"
996.\" 996.\"
997.Ss Search and Execution 997.Ss Search and Execution
998.\" 998.\"
999There are three types of commands: shell functions, built-in commands, and 999There are three types of commands: shell functions, built-in commands, and
1000normal programs \(em and the command is searched for (by name) in that order. 1000normal programs \(em and the command is searched for (by name) in that order.
1001A command that contains a slash 1001A command that contains a slash
1002.Sq \&/ 1002.Sq \&/
1003in its name is always a normal program. 1003in its name is always a normal program.
1004They each are executed in a different way. 1004They each are executed in a different way.
1005.Pp 1005.Pp
1006When a shell function is executed, all of the shell positional parameters 1006When a shell function is executed, all of the shell positional parameters
1007(note: excluding 1007(note: excluding
1008.Li 0 , 1008.Li 0 , \" $0
1009which is a special, not positional, parameter, and remains unchanged) 1009which is a special, not positional, parameter, and remains unchanged)
1010are set to the arguments of the shell function. 1010are set to the arguments of the shell function.
1011The variables which are explicitly placed in the environment of 1011The variables which are explicitly placed in the environment of
1012the command (by placing assignments to them before the function name) are 1012the command (by placing assignments to them before the function name) are
1013made local to the function and are set to the values given, 1013made local to the function and are set to the values given,
1014and exported for the benefit of programs executed with the function. 1014and exported for the benefit of programs executed with the function.
1015Then the command given in the function definition is executed. 1015Then the command given in the function definition is executed.
1016The positional parameters, and local variables, are restored to 1016The positional parameters, and local variables, are restored to
1017their original values when the command completes. 1017their original values when the command completes.
1018This all occurs within the current shell, and the function 1018This all occurs within the current shell, and the function
1019can alter variables, or other settings, of the shell, but 1019can alter variables, or other settings, of the shell, but
1020not the positional parameters nor their related special parameters. 1020not the positional parameters nor their related special parameters.
1021.Pp 1021.Pp
@@ -1583,58 +1583,58 @@ The @@ -1583,58 +1583,58 @@ The
1583.Ic set 1583.Ic set
1584built-in can also be used to set or reset them, and 1584built-in can also be used to set or reset them, and
1585.Ic shift 1585.Ic shift
1586can be used to manipulate the list. 1586can be used to manipulate the list.
1587.Pp 1587.Pp
1588To refer to the 10th (and later) positional parameters, 1588To refer to the 10th (and later) positional parameters,
1589the form 1589the form
1590.Li \&${ Ns Ar n Ns Li \&} 1590.Li \&${ Ns Ar n Ns Li \&}
1591must be used. 1591must be used.
1592Without the braces, a digit following 1592Without the braces, a digit following
1593.Dq $ 1593.Dq $
1594can only refer to one of the first 9 positional parameters, 1594can only refer to one of the first 9 positional parameters,
1595or the special parameter 1595or the special parameter
1596.Dv 0 . 1596.Dv 0 . \" $0
1597The word 1597The word
1598.Dq Li $10 1598.Dq Li $10
1599is treated identically to 1599is treated identically to
1600.Dq Li ${1}0 . 1600.Dq Li ${1}0 .
1601.\" 1601.\"
1602.\" 1602.\"
1603.Ss Special Parameters 1603.Ss Special Parameters
1604.\" 1604.\"
1605A special parameter is a parameter denoted by one of the following special 1605A special parameter is a parameter denoted by one of the following special
1606characters. 1606characters.
1607The value of the parameter is listed next to its character. 1607The value of the parameter is listed next to its character.
1608.Bl -tag -width thinhyphena 1608.Bl -tag -width thinhyphena
1609.It Dv * 1609.It Dv *
1610Expands to the positional parameters, starting from one. 1610Expands to the positional parameters, starting from one.
1611When the 1611When the
1612expansion occurs within a double-quoted string it expands to a single 1612expansion occurs within a double-quoted string it expands to a single
1613field with the value of each parameter separated by the first character of 1613field with the value of each parameter separated by the first character of
1614the 1614the
1615.Ev IFS 1615.Ev IFS
1616variable, or by a 1616variable, or by a
1617.Aq space 1617.Aq space
1618if 1618if
1619.Ev IFS 1619.Ev IFS
1620is unset. 1620is unset.
1621.It Dv @ 1621.It Dv @ \" $@
1622Expands to the positional parameters, starting from one. 1622Expands to the positional parameters, starting from one.
1623When the expansion occurs within double quotes, each positional 1623When the expansion occurs within double quotes, each positional
1624parameter expands as a separate argument. 1624parameter expands as a separate argument.
1625If there are no positional parameters, the 1625If there are no positional parameters, the
1626expansion of @ generates zero arguments, even when 1626expansion of @ generates zero arguments, even when
1627.Dv @ 1627.Dv $@
1628is double-quoted. 1628is double-quoted.
1629What this basically means, for example, is 1629What this basically means, for example, is
1630if 1630if
1631.Li $1 1631.Li $1
1632is 1632is
1633.Dq abc 1633.Dq abc
1634and 1634and
1635.Li $2 1635.Li $2
1636is 1636is
1637.Dq def\ ghi , 1637.Dq def\ ghi ,
1638then 1638then
1639.Li \*q$@\*q 1639.Li \*q$@\*q
1640expands to 1640expands to
@@ -1657,44 +1657,44 @@ Expands to the process ID of the invoked @@ -1657,44 +1657,44 @@ Expands to the process ID of the invoked
1657A sub-shell retains the same value of 1657A sub-shell retains the same value of
1658.Dv $ 1658.Dv $
1659as its parent. 1659as its parent.
1660.It Dv \&! 1660.It Dv \&!
1661Expands to the process ID of the most recent background 1661Expands to the process ID of the most recent background
1662command executed from the current shell. 1662command executed from the current shell.
1663For a pipeline, the process ID is that of the last command in the pipeline. 1663For a pipeline, the process ID is that of the last command in the pipeline.
1664If no background commands have yet been started by the shell, then 1664If no background commands have yet been started by the shell, then
1665.Dq Dv \&! 1665.Dq Dv \&!
1666will be unset. 1666will be unset.
1667Once set, the value of 1667Once set, the value of
1668.Dq Dv \&! 1668.Dq Dv \&!
1669will be retained until another background command is started. 1669will be retained until another background command is started.
1670.It Dv 0 No (zero) 1670.It Dv 0 No (zero) \" $0
1671Expands to the name of the shell or shell script. 1671Expands to the name of the shell or shell script.
1672.El 1672.El
1673.\" 1673.\"
1674.\" 1674.\"
1675.Ss Word Expansions 1675.Ss Word Expansions
1676.\" 1676.\"
1677This section describes the various expansions that are performed on words. 1677This section describes the various expansions that are performed on words.
1678Not all expansions are performed on every word, as explained later. 1678Not all expansions are performed on every word, as explained later.
1679.Pp 1679.Pp
1680Tilde expansions, parameter expansions, command substitutions, arithmetic 1680Tilde expansions, parameter expansions, command substitutions, arithmetic
1681expansions, and quote removals that occur within a single word expand to a 1681expansions, and quote removals that occur within a single word expand to a
1682single field. 1682single field.
1683It is only field splitting or pathname expansion that can 1683It is only field splitting or pathname expansion that can
1684create multiple fields from a single word. 1684create multiple fields from a single word.
1685The single exception to this 1685The single exception to this
1686rule is the expansion of the special parameter 1686rule is the expansion of the special parameter
1687.Dv @ 1687.Dv @ \" $@
1688within double quotes, as was described above. 1688within double quotes, as was described above.
1689.Pp 1689.Pp
1690The order of word expansion is: 1690The order of word expansion is:
1691.Bl -enum 1691.Bl -enum
1692.It 1692.It
1693Tilde Expansion, Parameter Expansion, Command Substitution, 1693Tilde Expansion, Parameter Expansion, Command Substitution,
1694Arithmetic Expansion (these all occur at the same time). 1694Arithmetic Expansion (these all occur at the same time).
1695.It 1695.It
1696Field Splitting is performed on fields 1696Field Splitting is performed on fields
1697generated by step (1) unless the 1697generated by step (1) unless the
1698.Ev IFS 1698.Ev IFS
1699variable is null. 1699variable is null.
1700.It 1700.It
@@ -1755,27 +1755,27 @@ is substituted. @@ -1755,27 +1755,27 @@ is substituted.
1755.Pp 1755.Pp
1756The parameter name or symbol can be enclosed in braces, 1756The parameter name or symbol can be enclosed in braces,
1757which are optional in this simple case, 1757which are optional in this simple case,
1758except for positional parameters with more than one digit or 1758except for positional parameters with more than one digit or
1759when parameter is followed by a character that could be interpreted as 1759when parameter is followed by a character that could be interpreted as
1760part of the name. 1760part of the name.
1761If a parameter expansion occurs inside double quotes: 1761If a parameter expansion occurs inside double quotes:
1762.Bl -enum 1762.Bl -enum
1763.It 1763.It
1764pathname expansion is not performed on the results of the expansion; 1764pathname expansion is not performed on the results of the expansion;
1765.It 1765.It
1766field splitting is not performed on the results of the 1766field splitting is not performed on the results of the
1767expansion, with the exception of the special rules for 1767expansion, with the exception of the special rules for
1768.Dv @ . 1768.Dv @ . \" $@
1769.El 1769.El
1770.Pp 1770.Pp
1771In addition, a parameter expansion where braces are used, 1771In addition, a parameter expansion where braces are used,
1772can be modified by using one of the following formats. 1772can be modified by using one of the following formats.
1773If the 1773If the
1774.Sq Ic \&: 1774.Sq Ic \&:
1775is omitted in the following modifiers, then the test in the expansion 1775is omitted in the following modifiers, then the test in the expansion
1776applies only to unset parameters, not null ones. 1776applies only to unset parameters, not null ones.
1777.Bl -tag -width aaparameterwordaaaaa 1777.Bl -tag -width aaparameterwordaaaaa
1778.It Li ${ Ns Ar parameter Ns Ic :- Ns Ar word Ns Li } 1778.It Li ${ Ns Ar parameter Ns Ic :- Ns Ar word Ns Li }
1779.Sy Use Default Values. 1779.Sy Use Default Values.
1780If 1780If
1781.Ar parameter 1781.Ar parameter
@@ -1829,27 +1829,27 @@ in this expansion. @@ -1829,27 +1829,27 @@ in this expansion.
1829.Sy String Length. 1829.Sy String Length.
1830The length in characters of the value of 1830The length in characters of the value of
1831.Ar parameter . 1831.Ar parameter .
1832.El 1832.El
1833.Pp 1833.Pp
1834The following four varieties of parameter expansion provide for substring 1834The following four varieties of parameter expansion provide for substring
1835processing. 1835processing.
1836In each case, pattern matching notation (see 1836In each case, pattern matching notation (see
1837.Sx Shell Patterns ) , 1837.Sx Shell Patterns ) ,
1838rather than regular expression notation, is used to evaluate the patterns. 1838rather than regular expression notation, is used to evaluate the patterns.
1839If parameter is 1839If parameter is
1840.Dv * 1840.Dv *
1841or 1841or
1842.Dv @ , 1842.Dv @ , \" $@
1843the result of the expansion is unspecified. 1843the result of the expansion is unspecified.
1844Enclosing the full parameter expansion string in double quotes does not 1844Enclosing the full parameter expansion string in double quotes does not
1845cause the following four varieties of pattern characters to be quoted, 1845cause the following four varieties of pattern characters to be quoted,
1846whereas quoting characters within the braces has this effect. 1846whereas quoting characters within the braces has this effect.
1847.Bl -tag -width aaparameterwordaaaaa 1847.Bl -tag -width aaparameterwordaaaaa
1848.It Li ${ Ns Ar parameter Ns Ic % Ns Ar word Ns Li } 1848.It Li ${ Ns Ar parameter Ns Ic % Ns Ar word Ns Li }
1849.Sy Remove Smallest Suffix Pattern. 1849.Sy Remove Smallest Suffix Pattern.
1850The 1850The
1851.Ar word 1851.Ar word
1852is expanded to produce a pattern. 1852is expanded to produce a pattern.
1853The parameter expansion then results in 1853The parameter expansion then results in
1854.Ar parameter , 1854.Ar parameter ,
1855with the 1855with the
@@ -2867,35 +2867,35 @@ not to the global variable named @@ -2867,35 +2867,35 @@ not to the global variable named
2867Another way to view this, is as if the shell just has one flat, global, 2867Another way to view this, is as if the shell just has one flat, global,
2868namespace, in which all variables exist. 2868namespace, in which all variables exist.
2869The 2869The
2870.Ic local 2870.Ic local
2871command conceptually copies the variable(s) named to unnamed temporary 2871command conceptually copies the variable(s) named to unnamed temporary
2872variables, and when the function ends, copies them back again. 2872variables, and when the function ends, copies them back again.
2873All references to the variables reference the same global variables, 2873All references to the variables reference the same global variables,
2874but while the function is active, after the 2874but while the function is active, after the
2875.Ic local 2875.Ic local
2876command has run, the values and attributes of the variables might 2876command has run, the values and attributes of the variables might
2877be altered, and later, when the function completes, be restored. 2877be altered, and later, when the function completes, be restored.
2878.Pp 2878.Pp
2879Note that the positional parameters 2879Note that the positional parameters
2880.Li 1 , 2880.Li 1 , \" $1
2881.Li 2 , 2881.Li 2 , \" $2
2882\&... (see 2882\&... (see
2883.Sx Positional Parameters ) , 2883.Sx Positional Parameters ) ,
2884and the special parameters 2884and the special parameters
2885.Li \&# , 2885.Li \&# , \" $#
2886.Li \&* 2886.Li \&* \" $*
2887and 2887and
2888.Li \&@ 2888.Li \&@ \" $@
2889(see 2889(see
2890.Sx Special Parameters ) , 2890.Sx Special Parameters ) ,
2891are always made local in all functions, and are reset inside the 2891are always made local in all functions, and are reset inside the
2892function to represent the options and arguments passed to the function. 2892function to represent the options and arguments passed to the function.
2893Note that 2893Note that
2894.Li $0 2894.Li $0
2895however retains the value it had outside the function, 2895however retains the value it had outside the function,
2896as do all the other special parameters. 2896as do all the other special parameters.
2897.Pp 2897.Pp
2898The only special parameter that can optionally be made local is 2898The only special parameter that can optionally be made local is
2899.Dq Li \- . 2899.Dq Li \- .
2900Making 2900Making
2901.Dq Li \- 2901.Dq Li \-
@@ -3162,27 +3162,27 @@ has no parameters, and exits with an exi @@ -3162,27 +3162,27 @@ has no parameters, and exits with an exi
3162an attempt is made to give it an option. 3162an attempt is made to give it an option.
3163.It Ic trap Ar action signal ... 3163.It Ic trap Ar action signal ...
3164.It Ic trap \- 3164.It Ic trap \-
3165.It Ic trap Op Fl l 3165.It Ic trap Op Fl l
3166.It Ic trap Oo Fl p Oc Ar signal ... 3166.It Ic trap Oo Fl p Oc Ar signal ...
3167.It Ic trap Ar N signal ... 3167.It Ic trap Ar N signal ...
3168.Pp 3168.Pp
3169Cause the shell to parse and execute action when any of the specified 3169Cause the shell to parse and execute action when any of the specified
3170signals are received. 3170signals are received.
3171The signals are specified by signal number or as the name of the signal. 3171The signals are specified by signal number or as the name of the signal.
3172If 3172If
3173.Ar signal 3173.Ar signal
3174is 3174is
3175.Li 0 3175.Li 0 \" $0
3176or its equivalent, 3176or its equivalent,
3177.Li EXIT , 3177.Li EXIT ,
3178the action is executed when the shell exits. 3178the action is executed when the shell exits.
3179The 3179The
3180.Ar action 3180.Ar action
3181may be a null (empty) string, 3181may be a null (empty) string,
3182which causes the specified signals to be ignored. 3182which causes the specified signals to be ignored.
3183With 3183With
3184.Ar action 3184.Ar action
3185set to 3185set to
3186.Sq Li - 3186.Sq Li -
3187the specified signals are set to their default actions. 3187the specified signals are set to their default actions.
3188If the first 3188If the first