[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Documentation patch: Add "$" to description of special parameters
From: |
Keith Thompson |
Subject: |
Documentation patch: Add "$" to description of special parameters |
Date: |
Thu, 28 Nov 2013 09:31:19 -0800 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
-DCONF_VENDOR='unknown'
-DLOCALEDIR='/usr/local/apps/bash-2013-11-27-160206/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include
-I./lib -g -O2
uname output: Linux bomb20 3.5.0-23-generic #35-Ubuntu SMP Thu Jan 24
13:15:40 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu
Bash Version: 4.2
Patch Level: 45
Release Status: release
Description:
It's difficult to find the documentation for bash's special parameters:
$* $@ $# $? $- $$ $! $0 $_
The bash documentation shows them without their leading dollar signs,
making it difficult to search for them
Repeat-By:
Typing "info bash" and searching for \$#, for example, finds
several mentions of "$#", but it doesn't find the definition
in section 3.4.2 "Special Parameters".
Furthermore, Google searches for punctuation are notoriously
difficult.
In my opinion, something like:
The special parameters `$*' and `$@' have special meaning ...
is more readable than
The special parameters `*' and `@' have special meaning ...
Fix:
Apply the following patch, which updates section 3.4.2 of the
Bash manual. The patch applies to Bash-4.2 patch 44. I've also
included the patch as an e-mail attachment.
==================== CUT HERE ====================
diff --git doc/bashref.texi doc/bashref.texi
index ae982d5..dae2cfc 100644
--- doc/bashref.texi
+++ doc/bashref.texi
@@ -480,7 +480,7 @@ If enabled, history expansion will be performed
unless an @samp{!}
appearing in double quotes is escaped using a backslash.
The backslash preceding the @samp{!} is not removed.
-The special parameters @samp{*} and @samp{@@} have special meaning
+The special parameters @samp{$*} and @samp{$@@} have special meaning
when in double quotes (@pxref{Shell Parameter Expansion}).
@node ANSI-C Quoting
@@ -1270,9 +1270,9 @@ a @samp{&}, or a newline.
When a function is executed, the arguments to the
function become the positional parameters
during its execution (@pxref{Positional Parameters}).
-The special parameter @samp{#} that expands to the number of
+The special parameter @samp{$#} that expands to the number of
positional parameters is updated to reflect the change.
-Special parameter @code{0} is unchanged.
+Special parameter @code{$0} is unchanged.
The first element of the @env{FUNCNAME} variable is set to the
name of the function while the function is executing.
@@ -1302,7 +1302,7 @@ call.
Any command associated with the @code{RETURN} trap is executed
before execution resumes.
When a function completes, the values of the
-positional parameters and the special parameter @samp{#}
+positional parameters and the special parameter @samp{$#}
are restored to the values they had prior to the function's
execution. If a numeric argument is given to @code{return},
that is the function's return status; otherwise the function's
@@ -1423,7 +1423,7 @@ only be referenced; assignment to them is not allowed.
@vtable @code
-@item *
+@item $*
Expands to the positional parameters, starting from one. When the
expansion occurs within double quotes, it expands to a single word
with the value of each parameter separated by the first character
@@ -1437,7 +1437,7 @@ If @env{IFS} is null, the parameters are joined
without intervening
separators.
-@item @@
+@item $@@
Expands to the positional parameters, starting from one. When the
expansion occurs within double quotes, each parameter expands to a
separate word. That is, @code{"$@@"} is equivalent to
@@ -1450,28 +1450,28 @@ When there are no positional parameters,
@code{"$@@"} and
@code{$@@}
expand to nothing (i.e., they are removed).
-@item #
+@item $#
Expands to the number of positional parameters in decimal.
-@item ?
+@item $?
Expands to the exit status of the most recently executed foreground
pipeline.
-@item -
+@item $-
(A hyphen.) Expands to the current option flags as specified upon
invocation, by the @code{set}
builtin command, or those set by the shell itself
(such as the @option{-i} option).
-@item $
+@item $$
Expands to the process @sc{id} of the shell. In a @code{()} subshell, it
expands to the process @sc{id} of the invoking shell, not the subshell.
-@item !
+@item $!
Expands to the process @sc{id} of the most recently executed background
(asynchronous) command.
-@item 0
+@item $0
Expands to the name of the shell or shell script. This is set at
shell initialization. If Bash is invoked with a file of commands
(@pxref{Shell Scripts}), @code{$0} is set to the name of that file.
@@ -1480,7 +1480,7 @@ then @code{$0} is set to the first argument
after the string to be
executed, if one is present. Otherwise, it is set
to the filename used to invoke Bash, as given by argument zero.
-@item _
+@item $_
(An underscore.)
At shell startup, set to the absolute pathname used to invoke the
shell or shell script being executed as passed in the environment
==================== AND HERE ====================
--
Keith Thompson <Keith.S.Thompson@gmail.com>
bash-special-parameters.patch
Description: Binary data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Documentation patch: Add "$" to description of special parameters,
Keith Thompson <=