diff --git a/docs/commands/builtin/declare.md b/docs/commands/builtin/declare.md index 9094f5f..440f181 100644 --- a/docs/commands/builtin/declare.md +++ b/docs/commands/builtin/declare.md @@ -138,7 +138,7 @@ RHS. sum total a b c printf 'Final value of "total" is: %d\n' "$total" -\
function sum { +
function sum { typeset -n _result=$1 shift @@ -153,7 +153,7 @@ RHS. } a=(1 2 3); b=(6 5 4); c=(2 4 6) sum total a b c printf \'Final value of -\"total\" is: %d\\n\' \"\$total\" \ +\"total\" is: %d\\n\' \"\$total\"
`typeset -n` is currently implemented in ksh93, mksh, and Bash 4.3. Bash and mksh's implementations are quite similar, but much different from diff --git a/docs/commands/builtin/eval.md b/docs/commands/builtin/eval.md index 9a3009e..9cd455e 100644 --- a/docs/commands/builtin/eval.md +++ b/docs/commands/builtin/eval.md @@ -109,7 +109,7 @@ controlled carefully by the caller is a good way to use it. ~~ksh93~~ and zsh don't do this properly ([fixed](http://article.gmane.org/gmane.comp.programming.tools.ast.devel/686) in ksh 93v- 2012-10-24 alpha). Earlier versions of zsh work (with - `setopt POSIX_BUILTINS` \-- looks like a regression). This works + `setopt POSIX_BUILTINS` -- looks like a regression). This works correctly in Bash POSIX mode, Dash, and mksh. ```{=html} @@ -161,14 +161,14 @@ identical to those of [let](../../commands/builtin/let.md). ## See also - [BashFAQ 48 - eval and security - issues](http://mywiki.wooledge.org/BashFAQ/048) \-- **IMPORTANT** + issues](http://mywiki.wooledge.org/BashFAQ/048) -- **IMPORTANT** - [Another eval article](http://fvue.nl/wiki/Bash:_Why_use_eval_with_variable_expansion%3F) - [Indirection via eval](http://mywiki.wooledge.org/BashFAQ/006#Assigning_indirect.2BAC8-reference_variables) - [More indirection via eval](http://fvue.nl/wiki/Bash:_Passing_variables_by_reference) -- [Martin Väth's \"push\"](https://github.com/vaeth/push) \-- +- [Martin Väth's \"push\"](https://github.com/vaeth/push) -- `printf %q` work-alike for POSIX. - [The \"magic alias\" hack](http://www.chiark.greenend.org.uk/~sgtatham/aliases.html) diff --git a/docs/commands/builtin/let.md b/docs/commands/builtin/let.md index 274dfb6..91db394 100644 --- a/docs/commands/builtin/let.md +++ b/docs/commands/builtin/let.md @@ -41,12 +41,12 @@ command](../../syntax/ccmd/arithmetic_eval.md): $ echo "$a - $b - $?" 4 - 2 - 0 -\ Remember that inside arithmetic evaluation contexts, all + Remember that inside arithmetic evaluation contexts, all other expansions are processed as usual (from left-to-right), and the resulting text is evaluated as an arithmetic expression. Arithmetic already has a way to control precedence using parentheses, so it's very rare to need to nest arithmetic expansions within one another. It's -used above only to illustrate how this precedence works. \ +used above only to illustrate how this precedence works. Unlike `((`, being a simple command `let` has its own environment. In Bash, built-ins that can set variables process any arithmetic under diff --git a/docs/commands/builtin/mapfile.md b/docs/commands/builtin/mapfile.md index 1b408bb..fcad769 100644 --- a/docs/commands/builtin/mapfile.md +++ b/docs/commands/builtin/mapfile.md @@ -121,7 +121,7 @@ illustrates the callback behavior: Since redirects are syntactically allowed anywhere in a command, we put it before the printf to stay out of the way of additional arguments. -Rather than opening \"outfile\\" for appending on each call by +Rather than opening \"outfile\" for appending on each call by calculating the filename, open an FD for each first and calculate which FD to send output to by measuring the size of x mod 2. The zero-width format specification is used to absorb the index number argument. diff --git a/docs/commands/builtin/printf.md b/docs/commands/builtin/printf.md index c91d2ae..92b8800 100644 --- a/docs/commands/builtin/printf.md +++ b/docs/commands/builtin/printf.md @@ -1,16 +1,16 @@ # The printf command -\
FIXME Stranger, this is a very big +
FIXME Stranger, this is a very big topic that needs experience - please fill in missing information, extend -the descriptions, and correct the details if you can! \ \
[**Attention:**]{.underline} This is about the +the descriptions, and correct the details if you can!
[**Attention:**]{.underline} This is about the Bash-builtin command `printf` - however, the description should be nearly identical for an external command that follows POSIX(r). [GNU Awk](http://www.gnu.org/software/gawk/manual/gawk.html#Printf) expects a comma after the format string and between each of the arguments of a **printf** command. For examples, see: [code -snippet](../../printf?&.md#using_printf_inside_of_awk). \ +snippet](../../printf?&.md#using_printf_inside_of_awk).
Unlike other documentations, I don't want to redirect you to the manual page for the `printf()` C function family. However, if you\'re more @@ -57,7 +57,7 @@ argument!). The `-v` Option can't assign directly to array indexes in Bash versions older than Bash 4.1. -\ In versions newer than 4.1, one must be careful when + In versions newer than 4.1, one must be careful when performing expansions into the first non-option argument of printf as this opens up the possibility of an easy code injection vulnerability. @@ -66,11 +66,11 @@ this opens up the possibility of an easy code injection vulnerability. declare -a x='([0]="hi")' \...where the echo can of course be replaced with any arbitrary command. -If you must, either specify a hard-coded format string or use \-- to +If you must, either specify a hard-coded format string or use -- to signal the end of options. The exact same issue also applies to [read](../../commands/builtin/read.md), and a similar one to [mapfile](../../commands/builtin/mapfile.md), though performing expansions into -their arguments is less common. \ +their arguments is less common. ### Arguments @@ -97,7 +97,7 @@ Take care to avoid [word splitting](../../syntax/expansion/wordsplit.md), as accidentally passing the wrong number of arguments can produce wildly different and unexpected results. See [this article](../../syntax/words.md). -\ [**Again, attention:**]{.underline} When a numerical + [**Again, attention:**]{.underline} When a numerical format expects a number, the internal `printf`-command will use the common Bash arithmetic rules regarding the base. A command like the following example **will** throw an error, since `08` is not a valid @@ -105,7 +105,7 @@ octal number (`00` to `07`!): printf '%d\n' 08 -\ + ### Format strings @@ -216,8 +216,8 @@ argument corresponding to a `%b` format. `\v` Prints a vertical tabulator `\"` Prints a `'` `\?` Prints a `?` - `\` Interprets `` as **octal** number and prints the corresponding character from the character set - `\0` same as `\` + `` Interprets `` as **octal** number and prints the corresponding character from the character set + `\0` same as `` `\x` Interprets `` as **hexadecimal** number and prints the corresponding character from the character set (**3 digits**) `\u` same as `\x`, but **4 digits** `\U` same as `\x`, but **8 digits** @@ -412,7 +412,7 @@ fmt++; system's `/usr/bin/printf` or equivalent. The mksh maintainer recommends using `print`. The development version (post- R40f) adds a new parameter expansion in the form of `${name@Q}` which fills the - role of `printf %q` \-- expanding in a shell-escaped format. + role of `printf %q` -- expanding in a shell-escaped format. ```{=html} diff --git a/docs/commands/builtin/read.md b/docs/commands/builtin/read.md index 4360283..ddb6971 100644 --- a/docs/commands/builtin/read.md +++ b/docs/commands/builtin/read.md @@ -20,7 +20,7 @@ If `` is given, the line is word-split using ``. The remaining words are all assigned to the last `` if more words than variable names are present. -\ If no `` is given, the whole line + If no `` is given, the whole line read (without performing word-splitting!) is assigned to the shell variable [REPLY](../../syntax/shellvars.md#REPLY). Then, `REPLY` really contains the line as it was read, without stripping pre- and postfix spaces and @@ -30,7 +30,7 @@ other things! printf '"%s"\n' "$REPLY" done <<<" a line with prefix and postfix space " -\ + If a timeout is given, or if the shell variable [TMOUT](../../syntax/shellvars.md#TMOUT) is set, it is counted from initially @@ -61,7 +61,7 @@ Of course it's valid to set individual array elements without using read MYARRAY[5] -\ + Reading into array elements using the syntax above **may cause [pathname expansion](../../syntax/expansion/globs.md) to occur**. @@ -81,7 +81,7 @@ array name and index: read 'x[1]' -\ + ### Return status @@ -90,7 +90,7 @@ array name and index: 0 no error 0 error when assigning to a read-only variable [^1] 2 invalid option - \>128 timeout (see `-t`) + >128 timeout (see `-t`) !=0 invalid filedescriptor supplied to `-u` !=0 end-of-file reached diff --git a/docs/commands/builtin/set.md b/docs/commands/builtin/set.md index a5067d7..7f29036 100644 --- a/docs/commands/builtin/set.md +++ b/docs/commands/builtin/set.md @@ -41,7 +41,7 @@ set flags (true for most commands on UNIX(r)). `-v` `verbose` Print shell input lines as they are read - useful for debugging. `-x` `xtrace` Print commands just before execution - with all expansions and substitutions done, and words marked - useful for debugging. `-B` `braceexpand` The shell performs [brace expansion](../../syntax/expansion/brace.md) This is on by default. - `-C` \`noclobber` Don't overwrite files on redirection operations. You can override that by specifying the `>|` redirection operator when needed. See [redirection](../../syntax/redirection.md) + `-C` `noclobber` Don't overwrite files on redirection operations. You can override that by specifying the `>|` redirection operator when needed. See [redirection](../../syntax/redirection.md) `-E` `errtrace` `ERR`-traps are inherited by by shell functions, command substitutions, and commands executed in a subshell environment. `-H` `histexpand` Enable `!`-style history expansion. Defaults to `on` for interactive shells. `-P` `physical` Don't follow symlinks when changing directories - use the physical filesystem structure. diff --git a/docs/commands/builtin/shift.md b/docs/commands/builtin/shift.md index fb60a16..84573f1 100644 --- a/docs/commands/builtin/shift.md +++ b/docs/commands/builtin/shift.md @@ -63,26 +63,26 @@ There are no options. dash: 1: shift: can't shift that many ` In most shells, you can work around this problem using the [command](../../commands/builtin/command.md) builtin to suppress fatal - errors caused by *special builtins*. \ \$ dash -c \'f() { if - command shift 2\>/dev/null; then echo \"\$1\"; else echo \"no + errors caused by *special builtins*. \$ dash -c \'f() { if + command shift 2>/dev/null; then echo \"\$1\"; else echo \"no args\"; fi; }; f\' -no args \ While, POSIX requires this behavior, it isn't very +no args While, POSIX requires this behavior, it isn't very obvious and some shells don't do it correctly. To work around this, you can use something like: -\ \$ mksh -c \'f() { if ! \${1+false} && shift; then echo -\"\$1\"; else echo \"no args\"; fi; }; f\' no args \ ~~The mksh + \$ mksh -c \'f() { if ! \${1+false} && shift; then echo +\"\$1\"; else echo \"no args\"; fi; }; f\' no args ~~The mksh maintainer refuses to change either the `shift` or `command` builtins.~~ [Fixed](https://github.com/MirBSD/mksh/commit/996e05548ab82f7ef2dea61f109cc7b6d13837fa). (Thanks!) - Perhaps almost as bad as the above, busybox sh's `shift` always returns success, even when attempting to shift beyond the final - argument. \ \$ bb -c \'f() { if shift; then echo \"\$1\"; + argument. \$ bb -c \'f() { if shift; then echo \"\$1\"; else echo \"no args\"; fi; }; f\' -(no output) \ The above mksh workaround will work in this case +(no output) The above mksh workaround will work in this case too. ## See also diff --git a/docs/commands/classictest.md b/docs/commands/classictest.md index c000c2b..e804e78 100644 --- a/docs/commands/classictest.md +++ b/docs/commands/classictest.md @@ -87,60 +87,60 @@ Since Bash 4.1, all tests related to permissions respect ACLs, if the underlying | Operator syntax | Description | | ------------------------- | ----------------------------------------------------------------------------------------------- | -| **-a** | True if exists. :warning: (not recommended, may collide with `-a` for `AND`, see below) | -| **-e** | True if exists. | -| **-f** | True, if exists and is a **regular** file. | -| **-d** | True, if exists and is a **directory**. | -| **-c** | True, if exists and is a **character special** file. | -| **-b** | True, if exists and is a **block special** file. | -| **-p** | True, if exists and is a **named pipe** (FIFO). | -| **-S** | True, if exists and is a **socket** file. | -| **-L** | True, if exists and is a **symbolic link**. | -| **-h** | True, if exists and is a **symbolic link**. | -| **-g** | True, if exists and has **sgid bit** set. | -| **-u** | True, if exists and has **suid bit** set. | -| **-r** | True, if exists and is **readable**. | -| **-w** | True, if exists and is **writable**. | -| **-x** | True, if exists and is **executable**. | -| **-s** | True, if exists and has size bigger than 0 (**not empty**). | -| **-t** | True, if file descriptor is open and refers to a terminal. | -| **-nt** | True, if is **newer than** (mtime). :warning: | -| **-ot** | True, if is **older than** (mtime). :warning: | -| **-ef** | True, if and refer to the **same device and inode numbers**. :warning: | +| **-a** | True if exists. :warning: (not recommended, may collide with `-a` for `AND`, see below) | +| **-e** | True if exists. | +| **-f** | True, if exists and is a **regular** file. | +| **-d** | True, if exists and is a **directory**. | +| **-c** | True, if exists and is a **character special** file. | +| **-b** | True, if exists and is a **block special** file. | +| **-p** | True, if exists and is a **named pipe** (FIFO). | +| **-S** | True, if exists and is a **socket** file. | +| **-L** | True, if exists and is a **symbolic link**. | +| **-h** | True, if exists and is a **symbolic link**. | +| **-g** | True, if exists and has **sgid bit** set. | +| **-u** | True, if exists and has **suid bit** set. | +| **-r** | True, if exists and is **readable**. | +| **-w** | True, if exists and is **writable**. | +| **-x** | True, if exists and is **executable**. | +| **-s** | True, if exists and has size bigger than 0 (**not empty**). | +| **-t** | True, if file descriptor is open and refers to a terminal. | +| **-nt** | True, if is **newer than** (mtime). :warning: | +| **-ot** | True, if is **older than** (mtime). :warning: | +| **-ef** | True, if and refer to the **same device and inode numbers**. :warning: | ## String tests | Operator syntax | Description | | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| **-z** | True, if is **empty**. | -| **-n** | True, if is **not empty** (this is the default operation). | -| **=** | True, if the strings are **equal**. | -| **!=** | True, if the strings are **not equal**. | -| **<** | True if sorts **before** lexicographically (pure ASCII, not current locale!). Remember to escape! Use `\<` | -| **\>** | True if sorts **after** lexicographically (pure ASCII, not current locale!). Remember to escape! Use `\>` | +| **-z** | True, if is **empty**. | +| **-n** | True, if is **not empty** (this is the default operation). | +| **=** | True, if the strings are **equal**. | +| **!=** | True, if the strings are **not equal**. | +| **<** | True if sorts **before** lexicographically (pure ASCII, not current locale!). Remember to escape! Use `<` | +| **>** | True if sorts **after** lexicographically (pure ASCII, not current locale!). Remember to escape! Use `>` | ## Arithmetic tests | Operator syntax | Description | | ------------------------------- | ------------------------------------------------------------------- | -| **-eq** | True, if the integers are **equal**. | -| **-ne** | True, if the integers are **NOT equal**. | -| **-le** | True, if the first integer is **less than or equal** second one. | -| **-ge** | True, if the first integer is **greater than or equal** second one. | -| **-lt** | True, if the first integer is **less than** second one. | -| **-gt** | True, if the first integer is **greater than** second one. | +| **-eq** | True, if the integers are **equal**. | +| **-ne** | True, if the integers are **NOT equal**. | +| **-le** | True, if the first integer is **less than or equal** second one. | +| **-ge** | True, if the first integer is **greater than or equal** second one. | +| **-lt** | True, if the first integer is **less than** second one. | +| **-gt** | True, if the first integer is **greater than** second one. | ## Misc syntax | Operator syntax | Description | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------ | -| **-a** | True, if **and** are true (AND). Note that `-a` also may be used as a file test (see above) | -| **-o** | True, if either \ **or** is true (OR). | -| **!** | True, if is **false** (NOT). | -| **(** **)** | Group a test (for precedence). **Attention:** In normal shell-usage, the `(` and `)` must be escaped; use `\(` and `\)`! | -| **-o** | True, if the [shell option](../internals/shell_options.md) is set. | -| **-v** | True if the variable has been set. Use `var[n]` for array elements. | -| **-R** | True if the variable has been set and is a nameref variable (since 4.3-alpha) | +| **-a** | True, if **and** are true (AND). Note that `-a` also may be used as a file test (see above) | +| **-o** | True, if either **or** is true (OR). | +| **!** | True, if is **false** (NOT). | +| **(** **)** | Group a test (for precedence). **Attention:** In normal shell-usage, the `(` and `)` must be escaped; use `(` and `)`! | +| **-o** | True, if the [shell option](../internals/shell_options.md) is set. | +| **-v** | True if the variable has been set. Use `var[n]` for array elements. | +| **-R** | True if the variable has been set and is a nameref variable (since 4.3-alpha) | ## Number of Arguments Rules @@ -290,7 +290,7 @@ true For the test command, the precedence parenthesis are, as well, `( )`, but you need to escape or quote them, so that the shell doesn't try to interpret them: ```bash -$ if [ \( "true" -o -e /does/not/exist \) -a -e /does/not/exist ]; then echo true; else echo false; fi +$ if [ ( "true" -o -e /does/not/exist ) -a -e /does/not/exist ]; then echo true; else echo false; fi false # equivalent, but less readable IMHO: @@ -527,7 +527,7 @@ done - Internal: [conditional expression](../syntax/ccmd/conditional_expression.md) (aka "the new test command") - Internal: [the if-clause](../syntax/ccmd/if_clause.md) -[^1]: Of course, one can wonder what is the use of including the +[^1]: Of course, one can wonder what is the use of including the parenthesis in the specification without defining the behaviour with more than 4 arguments or how usefull are the examples with 7 or 9 - arguments attached to the specification. + arguments attached to the specification. diff --git a/docs/dict/exit_status.md b/docs/dict/exit_status.md index 96b2f21..fdc3390 100644 --- a/docs/dict/exit_status.md +++ b/docs/dict/exit_status.md @@ -68,7 +68,7 @@ negation (`! pipeline`). `` eval echo \$? <&0`false` `` 1 1 1 1 0 0 0 0 1 - `while :; do ! break; done; echo $?` 1 1 1 1 0 0 1 1 \- + `while :; do ! break; done; echo $?` 1 1 1 1 0 0 1 1 - [discussion](https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00009.html)`false; : | echo $?` 1 1 1 0 1 1 1 1 0 @@ -90,9 +90,9 @@ transparency of the return builtin. `f() { return $?; }; false; f; echo $?` 1 1 1 1 1 1 1 1 1 - `f() { ! return; }; f; echo $?` 0 0 1 0 0 0 1 1 \- + `f() { ! return; }; f; echo $?` 0 0 1 0 0 0 1 1 - - `f() { ! return; }; false; f; echo $?` 1 1 0 0 1 1 0 0 \- + `f() { ! return; }; false; f; echo $?` 1 1 0 0 1 1 0 0 - `` f() { return; }; x=`false` f; echo $? `` 1 1 1 1 0 0 0 0 0 diff --git a/docs/howto/dissectabadoneliner.md b/docs/howto/dissectabadoneliner.md index e6434dd..0a73a83 100644 --- a/docs/howto/dissectabadoneliner.md +++ b/docs/howto/dissectabadoneliner.md @@ -73,7 +73,7 @@ happen again. $ mkdir "$j" && cd "$j" && ... && cd .. ``` -That's almost right, but there's one problem \-- what happens if `$j` +That's almost right, but there's one problem -- what happens if `$j` contains a slash? Then `cd ..` will not return to the original directory. That's wrong! `cd -` causes cd to return to the previous working directory, so it's a much better choice: diff --git a/docs/howto/edit-ed.md b/docs/howto/edit-ed.md index a1799f4..b139952 100644 --- a/docs/howto/edit-ed.md +++ b/docs/howto/edit-ed.md @@ -341,8 +341,8 @@ read into memory. # equivalent ed -s file <<< 'g/foo/' -The name `grep` is derived from the notaion `g/RE/p` (global =\> regular -expression =\> print). ref +The name `grep` is derived from the notaion `g/RE/p` (global => regular +expression => print). ref ### wc -l diff --git a/docs/howto/getopts_tutorial.md b/docs/howto/getopts_tutorial.md index b1d3124..168f76d 100644 --- a/docs/howto/getopts_tutorial.md +++ b/docs/howto/getopts_tutorial.md @@ -90,7 +90,7 @@ which means [end of options](../dict/terms/end_of_options.md). ------------------------------------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [OPTIND](../syntax/shellvars.md#OPTIND) Holds the index to the next argument to be processed. This is how `getopts` \"remembers\" its own status between invocations. Also useful to shift the positional parameters after processing with `getopts`. `OPTIND` is initially set to 1, and **needs to be re-set to 1 if you want to parse anything again with getopts** [OPTARG](../syntax/shellvars.md#OPTARG) This variable is set to any argument for an option found by `getopts`. It also contains the option flag of an unknown option. - [OPTERR](../syntax/shellvars.md#OPTERR) (Values 0 or 1) Indicates if Bash should display error messages generated by the `getopts` builtin. The value is initialized to **1** on every shell startup - so be sure to always set it to **0** if you don't want to see annoying messages! **`OPTERR` is not specified by POSIX for the `getopts` builtin utility \-\-- only for the C `getopt()` function in `unistd.h` (`opterr`).** `OPTERR` is bash-specific and not supported by shells such as ksh93, mksh, zsh, or dash. + [OPTERR](../syntax/shellvars.md#OPTERR) (Values 0 or 1) Indicates if Bash should display error messages generated by the `getopts` builtin. The value is initialized to **1** on every shell startup - so be sure to always set it to **0** if you don't want to see annoying messages! **`OPTERR` is not specified by POSIX for the `getopts` builtin utility --- only for the C `getopt()` function in `unistd.h` (`opterr`).** `OPTERR` is bash-specific and not supported by shells such as ksh93, mksh, zsh, or dash. `getopts` also uses these variables for error reporting (they\'re set to value-combinations which arent possible in normal operation). @@ -111,7 +111,7 @@ where: #### The option-string The option-string tells `getopts` which options to expect and which of -them must have an argument. The syntax is very simple \-\-- every option +them must have an argument. The syntax is very simple --- every option character is simply named as is, this example-string would tell `getopts` to look for `-f`, `-A` and `-x`: @@ -219,7 +219,7 @@ options (letters preceded by a dash), so it wasn't triggered. $ ./go_test.sh /etc/passwd $ -Again \-\-- nothing happened. The **very same** case: `getopts` didn't +Again --- nothing happened. The **very same** case: `getopts` didn't see any valid or invalid options (letters preceded by a dash), so it wasn't triggered. diff --git a/docs/howto/mutex.md b/docs/howto/mutex.md index 660fcaa..3fa3114 100644 --- a/docs/howto/mutex.md +++ b/docs/howto/mutex.md @@ -53,8 +53,8 @@ they are succesfully locked, and can operate without colliding. Setting the timestamp is similar: One step to check the timespamp, a second step to set the timestamp. -\ [**Conclusion:**]{.underline} We need an -operation that does the check and the locking in one step. \ + [**Conclusion:**]{.underline} We need an +operation that does the check and the locking in one step. A simple way to get that is to create a **lock directory** - with the mkdir command. It will: @@ -84,7 +84,7 @@ atomic. Maybe a while loop checking continously for the existence of the lock in the background and sending a signal such as USR1, if the directory is not found, can be done. The signal would need to be trapped. I am sure there there is a better solution than this -suggestion* \-\-- *[sn18](sunny_delhi18@yahoo.com) 2009/12/19 08:24* +suggestion* --- *[sn18](sunny_delhi18@yahoo.com) 2009/12/19 08:24* **Note:** While perusing the Internet, I found some people asking if the `mkdir` method works \"on all filesystems\". Well, let's say it should. diff --git a/docs/howto/redirection_tutorial.md b/docs/howto/redirection_tutorial.md index 1cca8de..7bfa892 100644 --- a/docs/howto/redirection_tutorial.md +++ b/docs/howto/redirection_tutorial.md @@ -44,7 +44,7 @@ connected to `/dev/pts/5`. # Simple Redirections -## Output Redirection \"n\> file\" +## Output Redirection \"n> file\" `>` is probably the simplest redirection. @@ -97,7 +97,7 @@ pointing to `file`. The command will then start with: What will the command do with this descriptor? It depends. Often nothing. We will see later why we might want other file descriptors. -## Input Redirection \"n\< file\" +## Input Redirection \"n< file\" When you run a commandusing `command < file`, it changes the file descriptor `0` so that it looks like: @@ -148,7 +148,7 @@ descriptors. # More On File Descriptors -## Duplicating File Descriptor 2\>&1 +## Duplicating File Descriptor 2>&1 We have seen how to open (or redirect) file descriptors. Let us see how to duplicate them, starting with the classic `2>&1`. What does this @@ -213,9 +213,9 @@ Similarly for output file descriptors, writing a line to file descriptor `s` will append a line to a file as will writing a line to file descriptor `t`. -\The syntax is somewhat confusing in that you would think +The syntax is somewhat confusing in that you would think that the arrow would point in the direction of the copy, but it's -reversed. So it's `target>&source` effectively.\ +reversed. So it's `target>&source` effectively. So, as a simple example (albeit slightly contrived), is the following: @@ -225,7 +225,7 @@ So, as a simple example (albeit slightly contrived), is the following: exec 1>&3 # Copy 3 back into 1 echo Done # Output to original stdout -## Order Of Redirection, i.e., \"\> file 2\>&1\" vs. \"2\>&1 \>file\" +## Order Of Redirection, i.e., \"> file 2>&1\" vs. \"2>&1 >file\" While it doesn't matter where the redirections appears on the command line, their order does matter. They are set up from left to right. @@ -313,7 +313,7 @@ Then it sees our duplication `2>&1`: And voila, both `1` and `2` are redirected to file. -## Why sed 's/foo/bar/\' file \>file Doesn't Work +## Why sed 's/foo/bar/\' file >file Doesn't Work This is a common error, we want to modify a file using something that reads from a file and writes the result to `stdout`. To do this, we @@ -322,7 +322,7 @@ as we have seen, the redirections are setup before the command is actually executed. So **BEFORE** sed starts, standard output has already been redirected, -with the additional side effect that, because we used \>, \"file\" gets +with the additional side effect that, because we used >, \"file\" gets truncated. When `sed` starts to read the file, it contains nothing. ## exec @@ -438,11 +438,11 @@ it. It's probably better to do something like: #we don't need 3 any more I\'ve seen some people using this as a way to discard, say stderr, using -something like: command 2\>&-. Though it might work, I\'m not sure if +something like: command 2>&-. Though it might work, I\'m not sure if you can expect all applications to behave correctly with a closed stderr. -When in doubt, I use 2\>/dev/null. +When in doubt, I use 2>/dev/null. # An Example @@ -628,7 +628,7 @@ The shell is pretty loose about what it considers a valid redirect. While opinions probably differ, this author has some (strong) recommendations: -- **Always** keep redirections \"tightly grouped\" \-- that is, **do +- **Always** keep redirections \"tightly grouped\" -- that is, **do not** include whitespace anywhere within the redirection syntax except within quotes if required on the RHS (e.g. a filename that contains a space). Since shells fundamentally use whitespace to diff --git a/docs/howto/testing-your-scripts.md b/docs/howto/testing-your-scripts.md index 00a4774..e5feadc 100644 --- a/docs/howto/testing-your-scripts.md +++ b/docs/howto/testing-your-scripts.md @@ -23,7 +23,7 @@ We have a simple **stat.sh** script: echo "PYTHON LINES: $LINES" This script evaluate the number of python files and the number of python -code lines in the files. We can use it like **./stat.sh \** +code lines in the files. We can use it like **./stat.sh ** ### Create testsuit diff --git a/docs/misc/shell_humor.md b/docs/misc/shell_humor.md index a83587d..ff3e090 100644 --- a/docs/misc/shell_humor.md +++ b/docs/misc/shell_humor.md @@ -28,7 +28,7 @@ Usually Bash and/or Linux (GNU Toolset) specific. $ sed statement <<< cat cement - $ \(- + $ (- bash: (-: command not found $ echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc diff --git a/docs/scripting/bashbehaviour.md b/docs/scripting/bashbehaviour.md index 9b4cbbd..fa8e846 100644 --- a/docs/scripting/bashbehaviour.md +++ b/docs/scripting/bashbehaviour.md @@ -104,11 +104,11 @@ read any startup files in POSIX(r) mode. Mode `/etc/profile` `~/.bash_profile` `~/.bash_login` `~/.profile` `~/.bashrc` `${ENV}` ----------------------- ---------------- ------------------- ----------------- -------------- ------------- ---------- - Login shell X X X X \- \- - Interactive shell \- \- \- \- X \- - SH compatible login X \- \- X \- \- - SH compatible \- \- \- \- \- X - POSIX(r) compatiblity \- \- \- \- \- X + Login shell X X X X - - + Interactive shell - - - - X - + SH compatible login X - - X - - + SH compatible - - - - - X + POSIX(r) compatiblity - - - - - X ## Bash run modes diff --git a/docs/scripting/bashchanges.md b/docs/scripting/bashchanges.md index f6fafd5..b513955 100644 --- a/docs/scripting/bashchanges.md +++ b/docs/scripting/bashchanges.md @@ -39,7 +39,7 @@ For this topic, see also `gnu_errfmt` 3.0-alpha `force_fignore` 3.0-alpha `failglob` 3.0-alpha - `extquote` 3.0-alpha unsure \-- verify! + `extquote` 3.0-alpha unsure -- verify! `extdebug` 3.0-alpha `pipefail` (for `set -o`) 3.0 `functrace` (for `set -o`) 3.0 @@ -108,7 +108,7 @@ For this topic, see also `[[...]]`: new 2.02-alpha1 KSH93 `[[...]]`: regex support (`=~`) 3.0-alpha `[[...]]`: quotable right-hand-side of `=~` forces string matching 3.2-alpha for consistency with pattern matching - `[[...]]`: `<` and `>` operators respect locale 4.1-alpha for consistency, since 4.1-beta: ensure you have set compatiblity to \>4.0 (default) + `[[...]]`: `<` and `>` operators respect locale 4.1-alpha for consistency, since 4.1-beta: ensure you have set compatiblity to >4.0 (default) `test`/`[`/`[[`: `-v` 4.2-alpha check if a variable is set `test`/`[`/`[[`: `-v` 4.2-alpha support array syntax to check for elements `test`/`[`/`[[`: `-N` accepts nanoseconds 5.1-alpha diff --git a/docs/scripting/basics.md b/docs/scripting/basics.md index 4ea9454..9d7e884 100644 --- a/docs/scripting/basics.md +++ b/docs/scripting/basics.md @@ -61,12 +61,12 @@ a comment. The shebang is for the operating system, not for the shell. Programs that don't ignore such lines, may not work as shebang driven interpreters. -\ [**Attention:**]{.underline}When the + [**Attention:**]{.underline}When the specified interpreter is unavailable or not executable (permissions), you usually get a \"`bad interpreter`\" error message., If you get nothing and it fails, check the shebang. Older Bash versions will respond with a \"`no such file or directory`\" error for a nonexistant -interpreter specified by the shebang. \ +interpreter specified by the shebang. **Additional note:** When you specify `#!/bin/sh` as shebang and that's a link to a Bash, then Bash will run in POSIX(r) mode! See: diff --git a/docs/scripting/debuggingtips.md b/docs/scripting/debuggingtips.md index a248877..b0afe8e 100644 --- a/docs/scripting/debuggingtips.md +++ b/docs/scripting/debuggingtips.md @@ -347,9 +347,9 @@ Why? Because when printed literally, the `^M` makes the cursor go back to the beginning of the line. The whole error message is *printed*, but you *see* only part of it! -\ It's easy to imagine the `^M` is bad in other places + It's easy to imagine the `^M` is bad in other places too. If you get weird and illogical messages from your script, rule out -the possibility that`^M` is involved. Find and eliminate it! \ +the possibility that`^M` is involved. Find and eliminate it! ### How can I find and eliminate them? diff --git a/docs/scripting/obsolete.md b/docs/scripting/obsolete.md index ff066f6..9a65c81 100644 --- a/docs/scripting/obsolete.md +++ b/docs/scripting/obsolete.md @@ -18,9 +18,9 @@ of POSIX, and some may be incompatible with POSIX. Syntax Replacement Description ---------------------------------- --------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - `&>FILE` and `>&FILE` `>FILE 2>&1` This redirection syntax is short for `>FILE 2>&1` and originates in the C Shell. The latter form is especially uncommon and should never be used, and the explicit form using separate redirections is preferred over both. These shortcuts contribute to confusion about the copy descriptor because the syntax is unclear. They also introduce parsing ambiguity, and conflict with POSIX. Shells without this feature treat `cmd1 &>file cmd2` as: \"background `cmd1` and then execute `cmd2` with its stdout redirected to `file`\", which is the correct interpretation of this expression. See: [redirection](../syntax/redirection.md) \`\$ { bash; dash \/dev/null&\>/dev/fd/2 echo bar\' foo echo bar bar\` + `&>FILE` and `>&FILE` `>FILE 2>&1` This redirection syntax is short for `>FILE 2>&1` and originates in the C Shell. The latter form is especially uncommon and should never be used, and the explicit form using separate redirections is preferred over both. These shortcuts contribute to confusion about the copy descriptor because the syntax is unclear. They also introduce parsing ambiguity, and conflict with POSIX. Shells without this feature treat `cmd1 &>file cmd2` as: \"background `cmd1` and then execute `cmd2` with its stdout redirected to `file`\", which is the correct interpretation of this expression. See: [redirection](../syntax/redirection.md) \`\$ { bash; dash /dev/null&>/dev/fd/2 echo bar\' foo echo bar bar\` `$[EXPRESSION]` `$((EXPRESSION))` This undocumented syntax is completely replaced by the POSIX-conforming arithmetic expansion `$((EXPRESSION))`. It is unimplemented almost everywhere except Bash and Zsh. See [arithmetic expansion](../syntax/expansion/arith.md). [Some discussion](http://lists.gnu.org/archive/html/bug-bash/2012-04/msg00034.html). - `COMMAND\ |&\ COMMAND` `COMMAND 2>&1 | COMMAND` This is an alternate pipeline operator derived from Zsh. Officially, it is not considered deprecated by Bash, but I highly discourage it. It conflicts with the list operator used for [coprocess](../syntax/keywords/coproc.md) creation in most Korn shells. It also has confusing behavior. The stdout is redirected first like an ordinary pipe, while the stderr is actually redirected last \-- after other redirects preceding the pipe operator. Overall, it's pointless syntax bloat. Use an explicit redirect instead. + `COMMAND\ |&\ COMMAND` `COMMAND 2>&1 | COMMAND` This is an alternate pipeline operator derived from Zsh. Officially, it is not considered deprecated by Bash, but I highly discourage it. It conflicts with the list operator used for [coprocess](../syntax/keywords/coproc.md) creation in most Korn shells. It also has confusing behavior. The stdout is redirected first like an ordinary pipe, while the stderr is actually redirected last -- after other redirects preceding the pipe operator. Overall, it's pointless syntax bloat. Use an explicit redirect instead. `function\ NAME()\ COMPOUND-CMD` `NAME()\ COMPOUND-CMD` or `function\ NAME\ {\ CMDS;\ }` This is an amalgamation between the Korn and POSIX style function definitions - using both the `function` keyword and parentheses. It has no useful purpose and no historical basis or reason to exist. It is not specified by POSIX. It is accepted by Bash, mksh, zsh, and perhaps some other Korn shells, where it is treated as identical to the POSIX-style function. It is not accepted by AT&T ksh. It should never be used. See the next table for the `function` keyword. Bash doesn't have this feature documented as expressly deprecated. `for x; { ...;}` `do`, `done`, `in`, `esac`, etc. This undocumented syntax replaces the `do` and `done` reserved words with braces. Many Korn shells support various permutations on this syntax for certain compound commands like `for`, `case`, and `while`. Which ones and certain details like whether a newline or semicolon are required vary. Only `for` works in Bash. Needless to say, don't use it. @@ -75,6 +75,6 @@ surprised if you run across someone telling you not to use these. - [bashchanges](../scripting/bashchanges.md) - [Greg's BashFAQ 061: List of essential features added (with the Bash version tag)](BashFAQ>061) -- [Bash \<-\> POSIX Portability guide with a focus on +- [Bash <-> POSIX Portability guide with a focus on Dash](http://mywiki.wooledge.org/Bashism) - diff --git a/docs/scripting/posparams.md b/docs/scripting/posparams.md index dcc95a7..b3cb88a 100644 --- a/docs/scripting/posparams.md +++ b/docs/scripting/posparams.md @@ -97,7 +97,7 @@ While useful in another situation, this way is lacks flexibility. The maximum number of arguments is a fixedvalue - which is a bad idea if you write a script that takes many filenames as arguments. -=\> forget that one +=> forget that one ### Loops diff --git a/docs/scripting/style.md b/docs/scripting/style.md index d30b5bb..ba79222 100644 --- a/docs/scripting/style.md +++ b/docs/scripting/style.md @@ -372,7 +372,7 @@ operation status of your script. You know: **\"One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination -of their C programs.\"** *\-- Robert Firth* +of their C programs.\"** *-- Robert Firth* ## Misc diff --git a/docs/scripting/terminalcodes.md b/docs/scripting/terminalcodes.md index 4492a15..991ed85 100644 --- a/docs/scripting/terminalcodes.md +++ b/docs/scripting/terminalcodes.md @@ -295,7 +295,7 @@ switch to, to get the other 8 colors. This is a slightly modified version of Charles Cooke's colorful Mandelbrot plot scripts ([original w/ -screenshot](http://earth.gkhs.net/ccooke/shell.html)) \-- ungolfed, +screenshot](http://earth.gkhs.net/ccooke/shell.html)) -- ungolfed, optimized a bit, and without hard-coded terminal escapes. The `colorBox` function is [memoized](http://en.wikipedia.org/wiki/Memoization) to collect `tput` output only when required and output a new escape only diff --git a/docs/snipplets/add_color_to_your_scripts.md b/docs/snipplets/add_color_to_your_scripts.md index f25442c..e261f98 100644 --- a/docs/snipplets/add_color_to_your_scripts.md +++ b/docs/snipplets/add_color_to_your_scripts.md @@ -1,6 +1,6 @@ # Add Color to your scripts -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags : terminal, color +---- dataentry snipplet ---- snipplet_tags : terminal, color LastUpdate_dt : 2013-03-23 Contributors : Frank Lazzarini, Dan Douglas type : snipplet diff --git a/docs/snipplets/awkcsv.md b/docs/snipplets/awkcsv.md index 241f59d..bd1b9e9 100644 --- a/docs/snipplets/awkcsv.md +++ b/docs/snipplets/awkcsv.md @@ -1,6 +1,6 @@ # Using `awk` to deal with CSV that uses quoted/unquoted delimiters -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags : awk, csv +---- dataentry snipplet ---- snipplet_tags : awk, csv LastUpdate_dt : 2010-07-31 Contributors : SiegX (IRC) type : snipplet ------------------------------------------------------------------------ diff --git a/docs/snipplets/filesize.md b/docs/snipplets/filesize.md index b68af00..691b03d 100644 --- a/docs/snipplets/filesize.md +++ b/docs/snipplets/filesize.md @@ -1,6 +1,6 @@ # Show size of a file -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: files, file size +---- dataentry snipplet ---- snipplet_tags: files, file size LastUpdate_dt: 2010-07-31 Contributors: Frank Lazzarini type: snipplet ------------------------------------------------------------------------ diff --git a/docs/snipplets/kill_bg_job_without_message.md b/docs/snipplets/kill_bg_job_without_message.md index 996382b..64f7b0d 100644 --- a/docs/snipplets/kill_bg_job_without_message.md +++ b/docs/snipplets/kill_bg_job_without_message.md @@ -1,6 +1,6 @@ # Kill a background job without a message -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: kill, process +---- dataentry snipplet ---- snipplet_tags: kill, process management, jobs LastUpdate_dt: 2010-07-31 Contributors: Jan Schampera type: snipplet diff --git a/docs/snipplets/largestfile.md b/docs/snipplets/largestfile.md index 86eab6b..065c4f0 100644 --- a/docs/snipplets/largestfile.md +++ b/docs/snipplets/largestfile.md @@ -1,6 +1,6 @@ # Get largest file -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: directory, recursive, +---- dataentry snipplet ---- snipplet_tags: directory, recursive, find, crawl LastUpdate_dt: 2013-03-23 Contributors: Dan Douglas type: snipplet diff --git a/docs/snipplets/pause_command.md b/docs/snipplets/pause_command.md index e1f44a2..8d7621d 100644 --- a/docs/snipplets/pause_command.md +++ b/docs/snipplets/pause_command.md @@ -1,6 +1,6 @@ # Pausing a script (like MSDOS pause command) -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: terminal, pause, input +---- dataentry snipplet ---- snipplet_tags: terminal, pause, input LastUpdate_dt: 2010-07-31 Contributors: Jan Schampera type: snipplet ------------------------------------------------------------------------ diff --git a/docs/snipplets/prargs.md b/docs/snipplets/prargs.md index b17328e..3497173 100644 --- a/docs/snipplets/prargs.md +++ b/docs/snipplets/prargs.md @@ -1,6 +1,6 @@ # Print argument list for testing -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: debug, arguments +---- dataentry snipplet ---- snipplet_tags: debug, arguments LastUpdate_dt: 2013-03-23 Contributors: Snappy (IRC), Dan Douglas type: snipplet diff --git a/docs/snipplets/print_horizontal_line.md b/docs/snipplets/print_horizontal_line.md index e33c795..affac7e 100644 --- a/docs/snipplets/print_horizontal_line.md +++ b/docs/snipplets/print_horizontal_line.md @@ -1,6 +1,6 @@ # Print a horizontal line -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: terminal, line +---- dataentry snipplet ---- snipplet_tags: terminal, line LastUpdate_dt: 2010-07-31 Contributors: Jan Schampera, prince_jammys, ccsalvesen, others type: snipplet diff --git a/docs/snipplets/rndstr.md b/docs/snipplets/rndstr.md index d72bb86..cd404e5 100644 --- a/docs/snipplets/rndstr.md +++ b/docs/snipplets/rndstr.md @@ -1,6 +1,6 @@ # Print a random string or select random elements -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: terminal, line +---- dataentry snipplet ---- snipplet_tags: terminal, line LastUpdate_dt: 2013-04-30 Contributors: Dan Douglas (ormaaj) type: snipplet @@ -31,7 +31,7 @@ basically the same principle as the `rndstr` function above. ~ $ ( set -- foo bar baz bork; printf '%s ' "${!_[_=RANDOM%$#+1,0]"{0..10}"}"; echo ) bork bar baz baz foo baz baz baz baz baz bork -\
This has some interesting option parsing concepts, but is +
This has some interesting option parsing concepts, but is overly complex. This is a good example of working too hard to avoid an eval for no benefit and some performance penalty. :/ @@ -63,7 +63,7 @@ rndstr() fi ``` -\ +
The remaining examples don't use quite the same tricks, which will hopefully be explained elsewhere eventually. See @@ -83,7 +83,7 @@ printf '%.1s' "${a[RANDOM%${#a[@]}]}"{0..9} $'\n' The extra detail that makes this work is to notice that in Bash, [brace expansion](../syntax/expansion/brace.md) is usually the very first type of expansion to be processed, always before parameter expansion. Bash is -unique in this respect \-- all other shells with a brace expansion +unique in this respect -- all other shells with a brace expansion feature perform it almost last, just before pathname expansion. First the sequence expansion generates ten parameters, then the parameters are expanded left-to-right causing the [arithmetic](../syntax/arith_expr.md) for diff --git a/docs/snipplets/screen_saverestore.md b/docs/snipplets/screen_saverestore.md index a1ca56a..9b9d693 100644 --- a/docs/snipplets/screen_saverestore.md +++ b/docs/snipplets/screen_saverestore.md @@ -1,6 +1,6 @@ # Save and restore terminal/screen content -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: terminal, restore +---- dataentry snipplet ---- snipplet_tags: terminal, restore screen LastUpdate_dt: 2010-07-31 Contributors: Greg Wooledge type: snipplet diff --git a/docs/snipplets/ssh_fetchkeys.md b/docs/snipplets/ssh_fetchkeys.md index e9de8be..56e5091 100644 --- a/docs/snipplets/ssh_fetchkeys.md +++ b/docs/snipplets/ssh_fetchkeys.md @@ -1,6 +1,6 @@ # Fetching SSH hostkeys without interaction -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: ssh, ssh-keys +---- dataentry snipplet ---- snipplet_tags: ssh, ssh-keys LastUpdate_dt: 2010-07-31 Contributors: Jan Schampera ------------------------------------------------------------------------ diff --git a/docs/snipplets/ssh_local_var.md b/docs/snipplets/ssh_local_var.md index 093c07b..a3a93c7 100644 --- a/docs/snipplets/ssh_local_var.md +++ b/docs/snipplets/ssh_local_var.md @@ -1,6 +1,6 @@ # Run some bash commands with SSH remotely using local variables -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: ssh, variables +---- dataentry snipplet ---- snipplet_tags: ssh, variables LastUpdate_dt: 2010-07-31 Contributors: cweiss type: snipplet ------------------------------------------------------------------------ diff --git a/docs/snipplets/wrapperargs.md b/docs/snipplets/wrapperargs.md index aaa1bb4..0b41326 100644 --- a/docs/snipplets/wrapperargs.md +++ b/docs/snipplets/wrapperargs.md @@ -1,6 +1,6 @@ # Generate code with own arguments properly quoted -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: arguments, quoting, +---- dataentry snipplet ---- snipplet_tags: arguments, quoting, escaping, wrapper LastUpdate_dt: 2010-07-31 Contributors: Jan Schampera type: snipplet diff --git a/docs/snipplets/xclip.md b/docs/snipplets/xclip.md index e26572e..812aae4 100644 --- a/docs/snipplets/xclip.md +++ b/docs/snipplets/xclip.md @@ -1,6 +1,6 @@ # X-Clipboard on Commandline -\-\-\-- dataentry snipplet \-\-\-- snipplet_tags: clipboard, x11, xclip, +---- dataentry snipplet ---- snipplet_tags: clipboard, x11, xclip, readline LastUpdate_dt: 2010-07-31 Contributors: Josh Triplett type: snipplet @@ -31,4 +31,4 @@ The behaviour is a bit tricky to explain: Of course you can use any other command, you\'re not limited to `xclip` here. -Note: C-@ as well as M-SPC both works and set the mark for me \-- pgas +Note: C-@ as well as M-SPC both works and set the mark for me -- pgas diff --git a/docs/syntax/arith_expr.md b/docs/syntax/arith_expr.md index 2e50bae..c683401 100644 --- a/docs/syntax/arith_expr.md +++ b/docs/syntax/arith_expr.md @@ -64,7 +64,7 @@ When no base is specified, the base 10 (decimal) is assumed, except when the prefixes as mentioned above (octals, hexadecimals) are present. The specified base can range from 2 to 64. To represent digits in a specified base greater than 10, characters other than 0 to 9 are needed -(in this order, low =\> high): +(in this order, low => high): - `0 ... 9` - `a ... z` @@ -223,7 +223,7 @@ That means, the following `if`-clause will execute the `else`-thread: `-` unary minus ` ? : ` conditional (ternary) operator\ - \ ? \ : \ + ? : ` , ` expression list @@ -232,7 +232,7 @@ That means, the following `if`-clause will execute the `else`-thread: ## Precedence -The operator precedence is as follows (highest -\> lowest): +The operator precedence is as follows (highest -> lowest): - Postfix (`id++`, `id--`) - Prefix (`++id`, `--id`) @@ -292,7 +292,7 @@ else fi ``` -\ Beware that `set -e` can change the + Beware that `set -e` can change the runtime behavior of scripts. For example, This non-equivalence of code behavior deserves some attention. Consider @@ -332,7 +332,7 @@ echo $? (\"SUCCESS\") This change in code behavior was discovered once the script was run -under set -e. \ +under set -e. ## Arithmetic expressions in Bash diff --git a/docs/syntax/arrays.md b/docs/syntax/arrays.md index cd4c399..3f574dd 100644 --- a/docs/syntax/arrays.md +++ b/docs/syntax/arrays.md @@ -131,9 +131,9 @@ As of now, arrays can't be exported. ### Getting values -\ For completeness and details on several parameter expansion + For completeness and details on several parameter expansion variants, see the [article about parameter expansion](../syntax/pe.md) and -check the notes about arrays. \ +check the notes about arrays. Syntax Description ----------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -185,7 +185,7 @@ It is best to [explicitly specify -v](../commands/builtin/unset.md#portability_considerations) when unsetting variables with unset. -\ Specifying unquoted array elements as arguments to any + Specifying unquoted array elements as arguments to any command, such as with the syntax above **may cause [pathname expansion](../syntax/expansion/globs.md) to occur** due to the presence of glob characters. @@ -205,7 +205,7 @@ To avoid this, **always quote** the array name and index: unset -v 'x[1]' This applies generally to all commands which take variable names as -arguments. Single quotes preferred. \ +arguments. Single quotes preferred. ## Usage @@ -369,13 +369,13 @@ strings would have been inserted into the integer array without evaluating the arithmetic. A special-case of this is shown in the next section. -\ Bash declaration commands are really keywords in disguise. They + Bash declaration commands are really keywords in disguise. They magically parse arguments to determine whether they are in the form of a valid assignment. If so, they are evaluated as assignments. If not, they are undergo normal argument expansion before being passed to the builtin which evaluates the resulting string as an assignment (somewhat like `eval`, but there are differences.) `'Todo:`\' Discuss this in detail. -\ + ### Indirection @@ -688,5 +688,5 @@ to generate these results. - [BashSheet - Arrays](http://mywiki.wooledge.org/BashSheet#Arrays) - Bashsheet quick-reference on Greycat's wiki. -\
vim: set fenc=utf-8 ff=unix ts=4 sts=4 sw=4 ft=dokuwiki et -wrap lbr: \ +
vim: set fenc=utf-8 ff=unix ts=4 sts=4 sw=4 ft=dokuwiki et +wrap lbr:
diff --git a/docs/syntax/basicgrammar.md b/docs/syntax/basicgrammar.md index 39d44c0..5fd8d21 100644 --- a/docs/syntax/basicgrammar.md +++ b/docs/syntax/basicgrammar.md @@ -38,11 +38,11 @@ can catch it and act on it. Exit code range is from 0 to 255, where 0 means success, and the rest mean either something failed, or there is an issue to report back to the calling program. -\ The simple command construct is the + The simple command construct is the **base** for all higher constructs. Everything you execute, from pipelines to functions, finally ends up in (many) simple commands. That's why Bash only has one method to [expand and execute a simple -command](../syntax/grammar/parser_exec.md). \ +command](../syntax/grammar/parser_exec.md). ## Pipelines @@ -115,7 +115,7 @@ A list is a sequence of one or more [pipelines](../basicgrammar.md#pipelines) separated by one of the operators `;`, `&`, `&&`, or `││`, and optionally terminated by one of `;`, `&`, or ``. -=\> It's a group of **pipelines** separated or terminated by **tokens** +=> It's a group of **pipelines** separated or terminated by **tokens** that all have **different meanings** for Bash. Your whole Bash script technically is one big single list! @@ -151,17 +151,17 @@ overview): Compound command syntax Description ------------------------------------------------------------ --------------------------------------------------------------------------------------------------------------------------------------------------------- - `( )` Execute `` in an extra subshell =\> [article](../syntax/ccmd/grouping_subshell.md) - `{ ; }` Execute `` as separate group (but not in a subshell) =\> [article](../syntax/ccmd/grouping_plain.md) - `(( ))` Evaluate the arithmetic expression `` =\> [article](../syntax/ccmd/arithmetic_eval.md) - `[[ ]]` Evaluate the conditional expression `` (aka \"the new test command\") =\> [article](../syntax/ccmd/conditional_expression.md) - `for in ; do ; done` Executes `` while setting the variable `` to one of `` on every iteration (classic for-loop) =\> [article](../syntax/ccmd/classic_for.md) - `for (( ; ; )) ; do ; done` C-style for-loop (driven by arithmetic expressions) =\> [article](../syntax/ccmd/c_for.md) - `select in ; do ; done` Provides simple menus =\> [article](../syntax/ccmd/user_select.md) - `case in ) ;; ... esac` Decisions based on pattern matching - executing `` on match =\> [article](../syntax/ccmd/case.md) - `if ; then ; else ; fi` The if clause: makes decisions based on exit codes =\> [article](../syntax/ccmd/if_clause.md) - `while ; do ; done` Execute `` while `` returns TRUE (exit code) =\> [article](../syntax/ccmd/while_loop.md) - `until ; do ; done` Execute `` until `` returns TRUE (exit code) =\> [article](../syntax/ccmd/until_loop.md) + `( )` Execute `` in an extra subshell => [article](../syntax/ccmd/grouping_subshell.md) + `{ ; }` Execute `` as separate group (but not in a subshell) => [article](../syntax/ccmd/grouping_plain.md) + `(( ))` Evaluate the arithmetic expression `` => [article](../syntax/ccmd/arithmetic_eval.md) + `[[ ]]` Evaluate the conditional expression `` (aka \"the new test command\") => [article](../syntax/ccmd/conditional_expression.md) + `for in ; do ; done` Executes `` while setting the variable `` to one of `` on every iteration (classic for-loop) => [article](../syntax/ccmd/classic_for.md) + `for (( ; ; )) ; do ; done` C-style for-loop (driven by arithmetic expressions) => [article](../syntax/ccmd/c_for.md) + `select in ; do ; done` Provides simple menus => [article](../syntax/ccmd/user_select.md) + `case in ) ;; ... esac` Decisions based on pattern matching - executing `` on match => [article](../syntax/ccmd/case.md) + `if ; then ; else ; fi` The if clause: makes decisions based on exit codes => [article](../syntax/ccmd/if_clause.md) + `while ; do ; done` Execute `` while `` returns TRUE (exit code) => [article](../syntax/ccmd/while_loop.md) + `until ; do ; done` Execute `` until `` returns TRUE (exit code) => [article](../syntax/ccmd/until_loop.md) ## Shell Function Definitions diff --git a/docs/syntax/ccmd/c_for.md b/docs/syntax/ccmd/c_for.md index 166de33..1cabd09 100644 --- a/docs/syntax/ccmd/c_for.md +++ b/docs/syntax/ccmd/c_for.md @@ -96,15 +96,15 @@ The return status is that of the last command executed from ``, or ## Alternatives and best practice -\
TODO: Show some alternate usages involving -functions and local variables for initialization.\ +
TODO: Show some alternate usages involving +functions and local variables for initialization.
## Examples ### Simple counter A simple counter, the loop iterates 101 times (\"0\" to \"100\" are 101 -numbers -\> 101 runs!), and everytime the variable `x` is set to the +numbers -> 101 runs!), and everytime the variable `x` is set to the current value. - It **initializes** `x = 0` @@ -132,7 +132,7 @@ will count from 0 to 100, but with a **step of 10**. This example loops through the bit-values of a Byte, beginning from 128, ending at 1. If that bit is set in the `testbyte`, it prints \"`1`\", -else \"`0`\" =\> it prints the binary representation of the `testbyte` +else \"`0`\" => it prints the binary representation of the `testbyte` value (8 bits). #!/usr/bin/env bash @@ -161,7 +161,7 @@ value (8 bits). # vim: set fenc=utf-8 ff=unix ft=sh : -\
+
testbyte=123 for (( n = 128 ; n >= 1 ; n /= 2 )); do @@ -173,7 +173,7 @@ value (8 bits). done echo -\ +
Why that one begins at 128 (highest value, on the left) and not 1 (lowest value, on the right)? It's easier to print from left to @@ -196,7 +196,7 @@ variables. printf '%*s\n' "$((n+1))" "$n" done -\ \~ \$ bash \<(xclip -o) 1 + \~ \$ bash <(xclip -o) 1 2 3 @@ -216,7 +216,7 @@ variables. 3 2 -1 \ +1 ## Portability considerations diff --git a/docs/syntax/ccmd/conditional_expression.md b/docs/syntax/ccmd/conditional_expression.md index ef84edd..6b517ec 100644 --- a/docs/syntax/ccmd/conditional_expression.md +++ b/docs/syntax/ccmd/conditional_expression.md @@ -52,7 +52,7 @@ When the operators `<` and `>` are used (string collation order), the test happens using the current locale when the `compat` level is greater than \"40\". -Operator precedence (highest =\> lowest): +Operator precedence (highest => lowest): - `( )` - `! ` @@ -151,7 +151,7 @@ Example: ### Behaviour differences compared to the builtin test command -As of Bash 4.1 alpha, the test primaries \'\<\' and \'\>\' (compare +As of Bash 4.1 alpha, the test primaries \'<\' and \'>\' (compare strings lexicographically) use the current locale settings, while the same primitives for the builtin test command don't. This leads to the following situation where they behave differently: @@ -159,8 +159,8 @@ following situation where they behave differently: $ ./cond.sh [[ ' 4' < '1' ]] --> exit 1 [[ 'step+' < 'step-' ]] --> exit 1 - [ ' 4' \< '1' ] --> exit 0 - [ 'step+' \< 'step-' ] --> exit 0 + [ ' 4' < '1' ] --> exit 0 + [ 'step+' < 'step-' ] --> exit 0 It won't be aligned. The conditional expression continues to respect the locate, as introduced with 4.1-alpha, the builtin `test`/`[` command diff --git a/docs/syntax/ccmd/grouping_plain.md b/docs/syntax/ccmd/grouping_plain.md index ea8c5f1..7dec041 100644 --- a/docs/syntax/ccmd/grouping_plain.md +++ b/docs/syntax/ccmd/grouping_plain.md @@ -64,8 +64,8 @@ the only compound command that's valid there: without extra separator (also in some other shells), **example**: `{ while sleep 1; do echo ZzZzzZ; done }` is valid. But this is not documented, infact the documentation explicitly says that a - semicolon or a newline must separate the enclosed list. \-- thanks + semicolon or a newline must separate the enclosed list. -- thanks `geirha` at Freenode [^2]: The main reason is the fact that in shell grammar, the curly - braces are not control operators but reserved words \-- TheBonsai + braces are not control operators but reserved words -- TheBonsai diff --git a/docs/syntax/expansion/brace.md b/docs/syntax/expansion/brace.md index 6e558eb..fcc97e5 100644 --- a/docs/syntax/expansion/brace.md +++ b/docs/syntax/expansion/brace.md @@ -209,7 +209,7 @@ Can be written as \...which is a kind of a hack, but hey, it works. -\
+
#### More fun @@ -234,7 +234,7 @@ In this case, the output is: eval printf "$arg"{,,}{,,}{,,}{,,}{,,}{,,}{,,,,,}{,,,,,}{,,,,,}{,,,,,}{,,,,,}{,,,,,} -\ +
## New in Bash 4.0 diff --git a/docs/syntax/expansion/proc_subst.md b/docs/syntax/expansion/proc_subst.md index 7b558df..33da05b 100644 --- a/docs/syntax/expansion/proc_subst.md +++ b/docs/syntax/expansion/proc_subst.md @@ -30,7 +30,7 @@ from a file). ### Scope -\ Note: According to multiple comments and sources, the + Note: According to multiple comments and sources, the scope of process substitution file descriptors is **not** stable, guaranteed, or specified by bash. Newer versions of bash (5.0+) seem to have shorter scope, and substitutions scope seems to be shorter than @@ -39,7 +39,7 @@ function scope. See and [stackoverflow](https://stackoverflow.com/questions/46660020/bash-what-is-the-scope-of-the-process-substitution); the latter discussion contains a script that can test the scoping -behavior case-by-case \ +behavior case-by-case If a process substitution is expanded as an argument to a function, expanded to an environment variable during calling of a function, or @@ -74,7 +74,7 @@ diff <(ls "$first_directory") <(ls "$second_directory") ``` This will compare the contents of each directory. In this command, each -*process* is *substituted* for a *file*, and diff doesn't see \<(bla), +*process* is *substituted* for a *file*, and diff doesn't see <(bla), it sees two files, so the effective command is something like ``` bash @@ -85,10 +85,10 @@ where those files are written to and destroyed automatically. ### Avoiding subshells -\ See Also: -[BashFAQ/024](http://mywiki.wooledge.org/BashFAQ/024) \-- *I set + See Also: +[BashFAQ/024](http://mywiki.wooledge.org/BashFAQ/024) -- *I set variables in a loop that's in a pipeline. Why do they disappear after -the loop terminates? Or, why can't I pipe data to read?* \ +the loop terminates? Or, why can't I pipe data to read?* One of the most common uses for process substitutions is to avoid the final subshell that results from executing a pipeline. The following is diff --git a/docs/syntax/expansion/tilde.md b/docs/syntax/expansion/tilde.md index 085657d..1a872b9 100644 --- a/docs/syntax/expansion/tilde.md +++ b/docs/syntax/expansion/tilde.md @@ -33,13 +33,13 @@ Tilde expansion is also performed everytime a variable is assigned: - after **every** `:` (colon) in the assigned value: `TARGET=file:~moonman/share` -\ As of now (Bash 4.3-alpha) the following constructs + As of now (Bash 4.3-alpha) the following constructs **also** works, though it's not a variable assignment: echo foo=~ echo foo=:~ -I don't know yet, if this is a bug or intended. \ +I don't know yet, if this is a bug or intended. This way you can correctly use the tilde expansion in your [PATH](../../syntax/shellvars.md#PATH): diff --git a/docs/syntax/expansion/wordsplit.md b/docs/syntax/expansion/wordsplit.md index a6b57a0..f7e3e01 100644 --- a/docs/syntax/expansion/wordsplit.md +++ b/docs/syntax/expansion/wordsplit.md @@ -18,9 +18,9 @@ are **not double-quoted**! The `IFS` variable holds the characters that Bash sees as word boundaries in this step. The default contains the characters -- \ -- \ -- \ +- +- +- These characters are also assumed when IFS is **unset**. When `IFS` is **empty** (nullstring), no word splitting is performed at all. @@ -34,7 +34,7 @@ the expansion result is split at these positions into multiple words. This doesn't happen when the expansion results were **double-quoted**. When a null-string (e.g., something that before expanded to -\>\>nothing\<\<) is found, it is removed, unless it is quoted (`''` or +>>nothing<<) is found, it is removed, unless it is quoted (`''` or `""`). [**Again note:**]{.underline} Without any expansion beforehand, Bash diff --git a/docs/syntax/grammar/parser_exec.md b/docs/syntax/grammar/parser_exec.md index 7cf6e9d..699c790 100644 --- a/docs/syntax/grammar/parser_exec.md +++ b/docs/syntax/grammar/parser_exec.md @@ -10,12 +10,12 @@ evaluate and execute is the simple command. ## Simple command expansion -\
+
- - -\ +
This step happens after the initial command line splitting. @@ -69,8 +69,8 @@ Otherwise, if a command name results: entire script to terminate* The behavior regarding the variable assignment errors can be tested: -\
\ +
**[This one exits the script completely]{.underline}** diff --git a/docs/syntax/keywords/coproc.md b/docs/syntax/keywords/coproc.md index bb37512..4b84057 100644 --- a/docs/syntax/keywords/coproc.md +++ b/docs/syntax/keywords/coproc.md @@ -227,7 +227,7 @@ which all do approximately the same thing. ksh93 and mksh have virtually identical syntax and semantics for coprocs. A *list* operator: `|&` is added to the language which runs the preceding *pipeline* as a coprocess (This is another reason not to use the special `|&` pipe operator in -Bash \-- its syntax is conflicting). The `-p` option to the `read` and +Bash -- its syntax is conflicting). The `-p` option to the `read` and `print` builtins can then be used to read and write to the pipe of the coprocess (whose FD isn't yet known). Special redirects are added to move the last spawned coprocess to a different FD: `<&p` and `>&p`, at @@ -261,7 +261,7 @@ The ability to use multiple coprocesses in Bash is considered \"experimental\". Bash will throw an error if you attempt to start more than one. This may be overridden at compile-time with the `MULTIPLE_COPROCS` option. However, at this time there are still issues -\-- see the above mailing list discussion. +-- see the above mailing list discussion. ## See also diff --git a/docs/syntax/pattern.md b/docs/syntax/pattern.md index 3a7c783..3b68b7c 100644 --- a/docs/syntax/pattern.md +++ b/docs/syntax/pattern.md @@ -55,23 +55,23 @@ Some simple examples using normal pattern matching: - Pattern `"Hello world"` matches - `Hello world` - Pattern `[Hh]"ello world"` matches - - =\> `Hello world` - - =\> `hello world` + - => `Hello world` + - => `hello world` - Pattern `Hello*` matches (for example) - - =\> `Hello world` - - =\> `Helloworld` - - =\> `HelloWoRlD` - - =\> `Hello` + - => `Hello world` + - => `Helloworld` + - => `HelloWoRlD` + - => `Hello` - Pattern `Hello world[[:punct:]]` matches (for example) - - =\> `Hello world!` - - =\> `Hello world.` - - =\> `Hello world+` - - =\> `Hello world?` + - => `Hello world!` + - => `Hello world.` + - => `Hello world+` + - => `Hello world?` - Pattern `[[.backslash.]]Hello[[.vertical-line.]]world[[.exclamation-mark.]]` matches (using [collation symbols](https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap07.html#tag_07_03_02_04)) - - =\> `\Hello|world!` + - => `\Hello|world!` ## Extended pattern language diff --git a/docs/syntax/pe.md b/docs/syntax/pe.md index 47b7402..33bf607 100644 --- a/docs/syntax/pe.md +++ b/docs/syntax/pe.md @@ -208,14 +208,14 @@ The `^` operator modifies the first character to uppercase, the `,` operator to lowercase. When using the double-form (`^^` and `,,`), all characters are converted. -\ + The (**currently undocumented**) operators `~` and `~~` reverse the case of the given text (in `PARAMETER`).`~` reverses the case of first letter of words in the variable while `~~` reverses case for all. Thanks to `Bushmills` and `geirha` on the Freenode IRC channel for this finding. -\ + [**Example: Rename all `*.txt` filenames to lowercase**]{.underline} @@ -245,13 +245,13 @@ examples: Assume: `array=(This is some Text)` - `echo "${array[@],}"` - - =\> `this is some text` + - => `this is some text` - `echo "${array[@],,}"` - - =\> `this is some text` + - => `this is some text` - `echo "${array[@]^}"` - - =\> `This Is Some Text` + - => `This Is Some Text` - `echo "${array[@]^^}"` - - =\> `THIS IS SOME TEXT` + - => `THIS IS SOME TEXT` ```{=html} @@ -267,7 +267,7 @@ Assume: `array=(This is some Text)` This expands to a list of all set **variable names** beginning with the string `PREFIX`. The elements of the list are separated by the first -character in the `IFS`-variable (\ by default). +character in the `IFS`-variable ( by default). This will show all defined variable names (not values!) beginning with \"BASH\": @@ -336,16 +336,16 @@ filename**. Just look at the following list with examples: - **Get name without extension** - `${FILENAME%.*}` - - =\> `bash_hackers.txt` + - => `bash_hackers.txt` - **Get extension** - `${FILENAME##*.}` - - =\> `bash_hackers.txt` + - => `bash_hackers.txt` - **Get directory name** - `${PATHNAME%/*}` - - =\> `/home/bash/bash_hackers.txt` + - => `/home/bash/bash_hackers.txt` - **Get filename** - `${PATHNAME##*/}` - - =\> `/home/bash/bash_hackers.txt` + - => `/home/bash/bash_hackers.txt` These are the syntaxes for filenames with a single extension. Depending on your needs, you might need to adjust shortest/longest match. @@ -362,7 +362,7 @@ expansion): Assume: `array=(This is a text)` - `echo "${array[@]%is}"` - - =\> `Th a text` + - => `Th a text` - (it was: `This is a text`) All other variants of this expansion behave the same. @@ -397,7 +397,7 @@ example string: ${MYSTRING//conservative/happy} -=\> +=> `Be liberal in what you accept, and conservativehappy in what you send` Since there is only one \"conservative\" in that example, it really @@ -410,13 +410,13 @@ but let's substitute it with \"by\". ${MYSTRING/in/by} -=\> `Be liberal inby what you accept, and conservative in what you send` +=> `Be liberal inby what you accept, and conservative in what you send` [**Second form: Substitute all occurrences**]{.underline} ${MYSTRING//in/by} -=\> +=> `Be liberal inby what you accept, and conservative inby what you send` [**Anchoring**]{.underline} Additionally you can \"anchor\" an @@ -447,9 +447,9 @@ A simple example, changing the (lowercase) letter `t` to `d`: Assume: `array=(This is a text)` - `echo "${array[@]/t/d}"` - - =\> `This is a dext` + - => `This is a dext` - `echo "${array[@]//t/d}"` - - =\> `This is a dexd` + - => `This is a dexd` ## String length @@ -462,7 +462,7 @@ expanded. Again, a quote from a big man, to have a test text: Using echo `${#MYSTRING}`\... -=\> `64` +=> `64` The length is reported in characters, not in bytes. Depending on your environment this may not always be the same (multibyte-characters, like @@ -484,9 +484,9 @@ Example: Assume: `array=(This is a text)` - `echo ${#array[1]}` - - =\> 2 (the word \"is\" has a length of 2) + - => 2 (the word \"is\" has a length of 2) - `echo ${#array[@]}` - - =\> 4 (the array contains 4 elements) + - => 4 (the array contains 4 elements) [**Attention:**]{.underline} The number of used elements does not need to conform to the highest index. Sparse arrays are possible in Bash, @@ -520,7 +520,7 @@ that the offset 0 is the first character: echo ${MYSTRING:35} -=\> +=> `Be liberal in what you accept, and conservative in what you send` ### Using Offset and Length @@ -529,7 +529,7 @@ In the second form we also give a length value: echo ${MYSTRING:35:12} -=\> +=> `Be liberal in what you accept, and conservative in what you send` ### Negative Offset Value @@ -554,7 +554,7 @@ then: echo "${MYSTRING:11:-17}" -=\> +=> `Be liberal in what you accept, and conservative in what you send` This works since Bash 4.2-alpha, see also @@ -575,9 +575,9 @@ Example: Assume: `array=(This is a text)` - `echo ${array[0]:2:2}` - - =\> `is` (the \"is\" in \"This\", array element 0) + - => `is` (the \"is\" in \"This\", array element 0) - `echo ${array[@]:1:2}` - - =\> `is a` (from element 1 inclusive, 2 elements are expanded, + - => `is a` (from element 1 inclusive, 2 elements are expanded, i.e. element 1 and 2) ## Use a default value diff --git a/docs/syntax/quoting.md b/docs/syntax/quoting.md index 79fd4f8..6a4f126 100644 --- a/docs/syntax/quoting.md +++ b/docs/syntax/quoting.md @@ -48,7 +48,7 @@ backslash: - The backslash changes the quotes into literals - otherwise Bash would interpret them -The sequence `\` (an unquoted backslash, followed by a +The sequence `` (an unquoted backslash, followed by a `` character) is interpreted as **line continuation**. It is removed from the input stream and thus effectively ignored. Use it to beautify your code: diff --git a/docs/syntax/redirection.md b/docs/syntax/redirection.md index 51b0bec..0efd471 100644 --- a/docs/syntax/redirection.md +++ b/docs/syntax/redirection.md @@ -1,6 +1,6 @@ # Redirection -\Fix me: To be continued\\ +Fix me: To be continued\ Redirection makes it possible to control where the output of a command goes to, and where the input of a command comes from. It's a mighty tool that, together with pipelines, makes the shell powerful. The @@ -16,9 +16,9 @@ file descriptors 0, 1 and 2, all connected to your terminal: `stdout` 1 standard output stream (e.g. monitor) `stderr` 2 standard error output stream (usually also on monitor) -\The terms \"monitor\" and \"keyboard\" refer to the +The terms \"monitor\" and \"keyboard\" refer to the same device, the **terminal** here. Check your preferred UNIX(r)-FAQ for -details, I\'m too lazy to explain what a terminal is ;-) \ +details, I\'m too lazy to explain what a terminal is ;-) Both, `stdout` and `stderr` are output file descriptors. Their difference is the **convention** that a program outputs payload on @@ -45,9 +45,9 @@ these examples are equivalent: cat >new.txt foo.txt bar.txt >new.txt cat foo.txt bar.txt -\Every redirection operator takes one or two +Every redirection operator takes one or two words as operands. If you have to use operands (e.g. filenames to -redirect to) that contain spaces you **must** quote them!\ +redirect to) that contain spaces you **must** quote them! ## Valid redirection targets and sources @@ -106,9 +106,9 @@ specified target. It's **equivalent** to Since Bash4, there's `&>>TARGET`, which is equivalent to `>> TARGET 2>&1`. -\This syntax is deprecated and should not be +This syntax is deprecated and should not be used. See the page about [obsolete and deprecated -syntax](../scripting/obsolete.md).\ +syntax](../scripting/obsolete.md). ## Appending redirected output and error output @@ -134,7 +134,7 @@ omitted, filedescriptor 0 (`stdin`) is assumed. ## Here documents -\ + <It seems that here-documents (tested on versions +It seems that here-documents (tested on versions `1.14.7`, `2.05b` and `3.1.17`) are correctly terminated when there is an EOF before the end-of-here-document tag. The reason is unknown, but it seems to be done on purpose. Bash 4 introduced a warning message when -end-of-file is seen before the tag is reached.\ +end-of-file is seen before the tag is reached. ## Here strings diff --git a/docs/syntax/shellvars.md b/docs/syntax/shellvars.md index cf3546a..d1ce263 100644 --- a/docs/syntax/shellvars.md +++ b/docs/syntax/shellvars.md @@ -1273,7 +1273,7 @@ Prompt](https://www.gnu.org/software/bash/manual/bash.html#Controlling-the-Promp Variable: `PS2` Since: unknown -------------- ----------------- ------------ ----------------- Type: normal variable Read-only: no - Set by Bash: if unset Default: \"\'\'\> \'\'\" + Set by Bash: if unset Default: \"\'\'> \'\'\" The value of this parameter is expanded as with PS1 and used as the secondary prompt string.