sh(1) patch

Giorgos Keramidas keramida at freebsd.org
Mon Nov 1 11:29:29 UTC 2004


On 2004-10-30 01:56, Alfred Perlstein <alfred at freebsd.org> wrote:
> I always find it kind of difficult to find the $foo special operators
> under the manpage for sh(1) because they are not listed in a way
> that allows easy search.
>
> Would this patch be acceptable?

> Index: sh.1
> ===================================================================
> RCS file: /home/ncvs/src/bin/sh/sh.1,v
> retrieving revision 1.92
> diff -u -r1.92 sh.1
> --- sh.1	3 Jul 2004 02:03:44 -0000	1.92
> +++ sh.1	30 Oct 2004 08:54:52 -0000
> @@ -952,7 +952,7 @@
>  The value of the parameter is listed
>  next to its character.
>  .Bl -hang
> -.It Li *
> +.It Li $*
> [snip]

Hi Alfred,

The patch is probably ok as an idea, but it's not quite finished if you only
change the names of the special variables to include `$'.  The paragraph just
above the changes says:

: Special Parameters
:   A special parameter is a parameter denoted by one of the following
:   special characters.  The value of the parameter is listed next to
:   its character.

This has to be changed too, if you change the list of variable names to
include the `$' character.  The best I could come up with was something
like the following diff.  Does this look any better to you?

[--- sh-special.patch starts here ---]
Index: sh.1
===================================================================
RCS file: /home/ncvs/src/bin/sh/sh.1,v
retrieving revision 1.92
diff -u -u -r1.92 sh.1
--- sh.1	3 Jul 2004 02:03:44 -0000	1.92
+++ sh.1	1 Nov 2004 11:27:04 -0000
@@ -947,12 +947,16 @@
 .Ic set
 built-in command can also be used to set or reset them.
 .Ss Special Parameters
-A special parameter is a parameter denoted by one of the following
-special characters.
-The value of the parameter is listed
-next to its character.
+A special parameter is a parameter denoted by a special one-character
+name.
+The special parameters recognized by the
+.Nm
+shell of
+.Fx
+are shown in the following list, exactly as they would appear in input
+typed by the user or in the source of a shell script.
 .Bl -hang
-.It Li *
+.It Li $*
 Expands to the positional parameters, starting from one.
 When
 the expansion occurs within a double-quoted string
@@ -965,7 +969,7 @@
 if
 .Ev IFS
 is unset.
-.It Li @
+.It Li $@
 Expands to the positional parameters, starting from one.
 When
 the expansion occurs within double-quotes, each positional
@@ -988,26 +992,26 @@
 .Bd -literal -offset indent
 "abc"   "def ghi"
 .Ed
-.It Li #
+.It Li $#
 Expands to the number of positional parameters.
-.It Li \&?
+.It Li $\&?
 Expands to the exit status of the most recent pipeline.
-.It Li -
+.It Li $-
 (hyphen) Expands to the current option flags (the single-letter
 option names concatenated into a string) as specified on
 invocation, by the set built-in command, or implicitly
 by the shell.
-.It Li $
+.It Li $$
 Expands to the process ID of the invoked shell.
 A subshell
 retains the same value of $ as its parent.
-.It Li \&!
+.It Li $\&!
 Expands to the process ID of the most recent background
 command executed from the current shell.
 For a
 pipeline, the process ID is that of the last command in the
 pipeline.
-.It Li 0
+.It Li $0
 (zero) Expands to the name of the shell or shell script.
 .El
 .Ss Word Expansions
[--- sh-special.patch ends here ---]



More information about the freebsd-doc mailing list