Skip to content

Commit 681cee9

Browse files
authored
Merge pull request #19 from sahal/formatting/fixes
Updated table formatting, call-outs, html comments, improper escapes.
2 parents de70cb8 + cd90135 commit 681cee9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2307
-2427
lines changed

docs/commands/builtin/caller.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
The `caller` builtin command is used to print execution frames of
1010
subroutine calls. Without giving a framenumber, the topmost execution
11-
frame information is printed (\"who called me\") wile linenumber and
11+
frame information is printed ("who called me") wile linenumber and
1212
filename.
1313

1414
When an execution frame number is given (0 - topmost), the linenumber,
@@ -22,10 +22,10 @@ used in a loop (see the examples section below).
2222

2323
The code below defines a function `die` that is used to exit the
2424
program. It prints a list of execution frames, starting with the topmost
25-
frame (0). The topmost frame is the \"caller of the die function\", in
26-
this case function \"f1\".
25+
frame (0). The topmost frame is the "caller of the die function", in
26+
this case function "f1".
2727

28-
This way, you can print a \"stack trace\" for debugging or logging
28+
This way, you can print a "stack trace" for debugging or logging
2929
purposes.
3030

3131
The code is made very simple, just to show the basic purposes.
@@ -70,9 +70,9 @@ f3
7070
[Bashdb](http://bashdb.sourceforge.net/) can assist in using some of
7171
Bash's more advanced debug features.
7272
- The Bash manpage and help text specifies that the argument to
73-
`caller` is an \"expr\" (whatever that means). Only an integer is
73+
`caller` is an "expr" (whatever that means). Only an integer is
7474
actually allowed, with no special interpretation of an
75-
\"expression\" as far as we can tell.
75+
"expression" as far as we can tell.
7676

7777
## Portability considerations
7878

docs/commands/builtin/declare.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ Below, `[-+]X` indicates an attribute, use `-X` to set the attribute,
3737

3838
`[-+]A` make NAMEs associative arrays
3939

40-
`[-+]c` **Undocumented** convert NAMEs to \"capcase\" on assignment (makes the first letter upper-case and the rest lower). Requires Bash built with `-DCASEMOD_CAPCASE`
40+
`[-+]c` **Undocumented** convert NAMEs to "capcase" on assignment (makes the first letter upper-case and the rest lower). Requires Bash built with `-DCASEMOD_CAPCASE`
4141

4242
`-f` restrict action or display to function names and definitions (removing with `+f` is valid syntax, but leads to an error message)
4343

4444
`-F` restrict display to function names only (plus line number and source file when debugging)
4545

4646
`-g` create global variables when used in a shell function; otherwise ignored (by default, `declare` declares local scope variables when used in shell functions)
4747

48-
`[-+]i` make NAMEs have the \"integer\" attribute
48+
`[-+]i` make NAMEs have the "integer" attribute
4949

5050
`[-+]l` convert NAMEs to lower case on assignment (makes sure the variable contains only lower case letters)
5151

52-
`[-+]n` make NAME a reference to the variable named by its value. Introduced in Bash 4.3-alpha.\
53-
\'\' \${!NAME}\'\' reveals the reference variable name, VALUE.\
54-
Use `unset -n NAME` to unset the variable. (`unset -v NAME` unsets the VALUE variable.)\
52+
`[-+]n` make NAME a reference to the variable named by its value. Introduced in Bash 4.3-alpha.
53+
''`${!NAME}`'' reveals the reference variable name, VALUE.
54+
Use `unset -n NAME` to unset the variable. (`unset -v NAME` unsets the VALUE variable.)
5555
Use `[[ -R NAME ]]` to test if NAME has been set to a VALUE, another variable's name.
5656

5757
`-p` display the attributes and value of each NAME
5858

5959
`[-+]r` make NAMEs readonly (removing with `+r` is valid syntax, but not possible)
6060

61-
`[-+]t` make NAMEs have the \"trace\" attribute (effective only for functions)
61+
`[-+]t` make NAMEs have the "trace" attribute (effective only for functions)
6262

6363
`[-+]u` convert NAMEs to upper case on assignment (makes sure the variable contains only upper case letters)
6464

@@ -76,13 +76,13 @@ Below, `[-+]X` indicates an attribute, use `-X` to set the attribute,
7676
!= 0 assignment to a readonly variable
7777
!= 0 removing the readonly-attribute from a readonly variable
7878
!= 0 assignment to an array variable without the compound assignment syntax (`array=(...)`)
79-
!= 0 attempt to use `+a` to \"destroy\" an array
79+
!= 0 attempt to use `+a` to "destroy" an array
8080
!= 0 attemt to display a non-existent function with `-f`
8181

8282
## Notes
8383

8484
Unix shells offer very few datatypes. Bash and some other shells extend
85-
this by allowing \"attributes\" to be set on variable names. The only
85+
this by allowing "attributes" to be set on variable names. The only
8686
attributes specified by POSIX are `export` and `readonly`, which are set
8787
by their own dedicated builtins. Datatypes in bash have a few other
8888
interesting capabilities such as the ability to modify data on
@@ -92,23 +92,23 @@ assignment.
9292

9393
### Display defined functions
9494

95-
`declare -f` can be used to display all defined functions\...
95+
`declare -f` can be used to display all defined functions...
9696

9797
$ declare -f
98-
foo ()
99-
{
98+
foo ()
99+
{
100100
echo "FOO is BAR"
101101
}
102-
world ()
103-
{
102+
world ()
103+
{
104104
echo "Hello World!"
105105
}
106106

107-
\...or just a specific defined function.
107+
...or just a specific defined function.
108108

109109
$ declare -f foo
110-
foo ()
111-
{
110+
foo ()
111+
{
112112
echo "FOO is BAR"
113113
}
114114

@@ -172,7 +172,7 @@ for details. ksh93 namerefs are much more powerful than Bash's.
172172
considers `typeset` a special builtin, while Bash does not - even in
173173
POSIX mode. If you use `typeset`, you should attempt to only use it
174174
in portable ways.
175-
- **todo** nameref portability\...
175+
- **todo** nameref portability...
176176

177177
## See also
178178

docs/commands/builtin/echo.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if given.
2929
`\a` alert (bell)
3030
`\b` backspace
3131
`\c` suppress further output
32-
`\e`
32+
`\e`
3333
`\E` an escape character
3434
`\f` form feed
3535
`\n` new line
@@ -56,17 +56,14 @@ if given.
5656
case `-n` is always treated as a string, and backslash escapes are
5757
interpreted by default. `dash` has the misfeature of following this
5858
and interpreting escapes by default, but includes a `-n` feature for
59-
suppressing newlines nevertheless.\
60-
\
61-
In practice, if you\'re able to assume a korn-like shell including
59+
suppressing newlines nevertheless.
60+
61+
In practice, if you're able to assume a korn-like shell including
6262
bash, mksh, or zsh, `echo` when used in simple cases is generally
6363
reliable. For example, in the very common situation in which echo is
6464
supplied with a single argument and whose output is to have a
6565
newline appended, using `echo` is considered common practice.
6666

67-
```{=html}
68-
<!-- -->
69-
```
7067
- **Never use options to `echo`! *Ever*!** Any time you feel tempted
7168
to use `echo -e`, `-n`, or any other special feature of echo, **use
7269
[printf](../../commands/builtin/printf.md) instead!** If portability is a
@@ -76,9 +73,6 @@ if given.
7673
\$\'\...\' \'\'if targeting only shells that support this special
7774
quoting style.
7875

79-
```{=html}
80-
<!-- -->
81-
```
8276
- `ksh93` has a `print` command, which if coding specifically for
8377
`ksh93` should be preferred over `echo`.
8478
[printf](../../commands/builtin/printf.md) still includes most of the

docs/commands/builtin/eval.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This code defines a set of identical functions using the supplied names.
5555
### Using printf %q
5656

5757
The `printf %q` format string performs shell escaping on its arguments.
58-
This makes `printf %q` the \"anti-eval\" - with each pass of a string
58+
This makes `printf %q` the "anti-eval" - with each pass of a string
5959
through printf requiring another `eval` to peel off the escaping again.
6060

6161
while (( ++n <= 5 )) || ! evalBall="eval $evalBall"; do
@@ -112,16 +112,11 @@ controlled carefully by the caller is a good way to use it.
112112
`setopt POSIX_BUILTINS` -- looks like a regression). This works
113113
correctly in Bash POSIX mode, Dash, and mksh.
114114

115-
```{=html}
116-
<!-- -->
117-
```
118115
- `eval` is another one of the few Bash builtins with keyword-like
119116
conditional parsing of arguments that are in the form of compound
120117
assignments.
121118

122-
```{=html}
123-
<!-- -->
124-
```
119+
125120
$ ( eval a=( a b\\ c d ); printf '<%s> ' "${a[@]}"; echo ) # Only works in Bash.
126121
<a> <b c> <d>
127122
$ ( x=a; eval "$x"=( a b\\ c d ); printf '<%s> ' "${a[@]}"; echo ) # Argument is no longer in the form of a valid assignment, therefore ordinary parsing rules apply.
@@ -168,7 +163,7 @@ identical to those of [let](../../commands/builtin/let.md).
168163
eval](http://mywiki.wooledge.org/BashFAQ/006#Assigning_indirect.2BAC8-reference_variables)
169164
- [More indirection via
170165
eval](http://fvue.nl/wiki/Bash:_Passing_variables_by_reference)
171-
- [Martin Väth's \"push\"](https://github.com/vaeth/push) --
166+
- [Martin Väth's "push"](https://github.com/vaeth/push) --
172167
`printf %q` work-alike for POSIX.
173-
- [The \"magic alias\"
168+
- [The "magic alias"
174169
hack](http://www.chiark.greenend.org.uk/~sgtatham/aliases.html)

docs/commands/builtin/kill.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The `kill` command is a Bash builtin command instead of relying on the
2727
external `kill` command of the operating system to
2828

2929
- be able to use shell job specifications instead of Unix process IDs
30-
- be able to send signals (\"kill something\") also, when your process
30+
- be able to send signals ("kill something") also, when your process
3131
limit is reached
3232

3333
### Options

docs/commands/builtin/let.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ The `let` builtin command evaluates each supplied word from left to
1010
right as an [arithmetic expression](../../syntax/arith_expr.md) and returns an
1111
exit code according to the truth value of the rightmost expression.
1212

13-
- 0 (TRUE) when `arg` evaluated to not 0 (arithmetic \"true\")
14-
- 1 (FALSE) when `arg` evaluated to 0 (arithmetic \"false\")
13+
- 0 (TRUE) when `arg` evaluated to not 0 (arithmetic "true")
14+
- 1 (FALSE) when `arg` evaluated to 0 (arithmetic "false")
1515

1616
For this return code mapping, please see [this
1717
section](../../syntax/arith_expr.md#arithmetic_expressions_and_return_codes).
@@ -50,7 +50,7 @@ used above only to illustrate how this precedence works. </WRAP>
5050

5151
Unlike `((`, being a simple command `let` has its own environment. In
5252
Bash, built-ins that can set variables process any arithmetic under
53-
their own environment, which makes the variable effectively \"local\" to
53+
their own environment, which makes the variable effectively "local" to
5454
the builtin unless the variable is also set or modified by the builtin.
5555
This differs in other shells, such as ksh93, where environment
5656
assignments to regular builtins are always local even if the variable is
@@ -84,7 +84,7 @@ needed.
8484
choose `let` over `((` expecting it to work in more places.
8585
- [expr(1)](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html#tag_20_42)
8686
is a command one is likely to come across sooner or later. While it
87-
is more \"standard\" than `let`, the above should always be
87+
is more "standard" than `let`, the above should always be
8888
preferred. Both [arithmetic expansion](../../syntax/arith_expr.md)s and the
8989
`[` test operator are specified by POSIX(r) and satisfy almost all
9090
of expr's use-cases. Unlike `let`, `expr` cannot assign directly to
@@ -108,4 +108,4 @@ needed.
108108
- Internal: [arithmetic evaluation compound
109109
command](../../syntax/ccmd/arithmetic_eval.md)
110110

111-
[^1]: \...
111+
[^1]: ...

docs/commands/builtin/local.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,20 @@ way, and takes all the same options, with 3 exceptions:
3030
have a builtin called `local`, but some such as `dash` and the
3131
busybox shell do.
3232

33-
```{=html}
34-
<!-- -->
35-
```
3633
- The behavior of function scope is not defined by POSIX, however
3734
local variables are implemented widely by bourne-like shells, and
3835
behavior differs substantially. Even the`dash` shell has local
3936
variables.
4037

41-
```{=html}
42-
<!-- -->
43-
```
4438
- In ksh93, using POSIX-style function definitions, `typeset` doesn't
4539
set `local` variables, but rather acts upon variables of the
4640
next-outermost scope (e.g. setting attributes). Using `typeset`
4741
within functions defined using ksh `function name {` syntax,
4842
variables follow roughly
4943
[lexical-scoping](http://community.schemewiki.org/?lexical-scope),
5044
except that functions themselves don't have scope, just like Bash.
51-
This means that even functions defined within a \"function's
52-
scope\" don't have access to non-local variables except through
45+
This means that even functions defined within a "function's
46+
scope" don't have access to non-local variables except through
5347
`namerefs`.
5448

5549
## See also

docs/commands/builtin/mapfile.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This builtin is also accessible using the command name `readarray`.
1414
handling standard input (the other being `read`). `mapfile` reads lines
1515
of standard input and assigns each to the elements of an indexed array.
1616
If no array name is given, the default array name is `MAPFILE`. The
17-
target array must be a \"normal\" integer indexed array.
17+
target array must be a "normal" integer indexed array.
1818

1919
`mapfile` returns success (0) unless an invalid option is given or the
2020
given array `ARRAY` is set readonly.
@@ -47,9 +47,9 @@ Here's a real-world example of interactive use borrowed from Gentoo
4747
workflow. Xorg updates require rebuilding drivers, and the
4848
Gentoo-suggested command is less than ideal, so let's Bashify it. The
4949
first command produces a list of packages, one per line. We can read
50-
those into the array named \"args\" using `mapfile`, stripping trailing
51-
newlines with the \'-t\' option. The resulting array is then expanded
52-
into the arguments of the \"emerge\" command - an interface to Gentoo's
50+
those into the array named "args" using `mapfile`, stripping trailing
51+
newlines with the '`-t`' option. The resulting array is then expanded
52+
into the arguments of the `emerge` command - an interface to Gentoo's
5353
package manager. This type of usage can make for a safe and effective
5454
replacement for xargs(1) in certain situations. Unlike xargs, all
5555
arguments are guaranteed to be passed to a single invocation of the
@@ -59,7 +59,7 @@ business.
5959
# eix --only-names -IC x11-drivers | { mapfile -t args; emerge -av1 "${args[@]}" <&1; }
6060

6161
Note the use of command grouping to keep the emerge command inside the
62-
pipe's subshell and within the scope of \"args\". Also note the unusual
62+
pipe's subshell and within the scope of "args". Also note the unusual
6363
redirection. This is because the -a flag makes emerge interactive,
6464
asking the user for confirmation before continuing, and checking with
6565
isatty(3) to abort if stdin isn't pointed at a terminal. Since stdin of
@@ -71,11 +71,11 @@ wiki: <http://mywiki.wooledge.org/BashFAQ/024>
7171
### The callback
7272

7373
This is one of the more unusual features of a Bash builtin. As far as
74-
I\'m able to tell, the exact behavior is as follows: If defined, as each
74+
I'm able to tell, the exact behavior is as follows: If defined, as each
7575
line is read, the code contained within the string argument to the -C
7676
flag is evaluated and executed *before* the assignment of each array
7777
element. There are no restrictions to this string, which can be any
78-
arbitrary code, however, two additional \"words\" are automatically
78+
arbitrary code, however, two additional "words" are automatically
7979
appended to the end before evaluation: the index, and corresponding line
8080
of data to be assigned to the next array element. Since all this happens
8181
before assignment, the callback feature cannot be used to modify the
@@ -91,9 +91,9 @@ the appended words from printf.
9191

9292
Really, the intended usage is for the callback to just contain the name
9393
of a function, with the extra words passed to it as arguments. If
94-
you\'re going to use callbacks at all, this is probably the best way
95-
because it allows for easy access to the arguments with no ugly \"code
96-
in a string\".
94+
you're going to use callbacks at all, this is probably the best way
95+
because it allows for easy access to the arguments with no ugly "code
96+
in a string".
9797

9898
$ foo() { echo "|$1|"; }; mapfile -n 11 -c 2 -C 'foo' <file
9999
|2|
@@ -121,13 +121,13 @@ illustrates the callback behavior:
121121

122122
Since redirects are syntactically allowed anywhere in a command, we put
123123
it before the printf to stay out of the way of additional arguments.
124-
Rather than opening \"outfile<n>\" for appending on each call by
124+
Rather than opening "outfile&lt;n&gt;" for appending on each call by
125125
calculating the filename, open an FD for each first and calculate which
126126
FD to send output to by measuring the size of x mod 2. The zero-width
127127
format specification is used to absorb the index number argument.
128128

129129
Another variation might be to add each of these lines to the elements of
130-
separate arrays. I\'ll leave dissecting this one as an exercise for the
130+
separate arrays. I'll leave dissecting this one as an exercise for the
131131
reader. This is quite the hack but illustrates some interesting
132132
properties of printf -v and mapfile -C (which you should probably never
133133
use in real code).
@@ -147,7 +147,7 @@ use in real code).
147147

148148
This example based on yet another #bash question illustrates mapfile in
149149
combination with read. The sample input is the heredoc to `main`. The
150-
goal is to build a \"struct\" based upon records in the input file made
150+
goal is to build a "struct" based upon records in the input file made
151151
up of the numbers following the colon on each line. Every 3rd line is a
152152
key followed by 2 corresponding fields. The showRecord function takes a
153153
key and returns the record.

0 commit comments

Comments
 (0)