Skip to content

Commit bf47c68

Browse files
authored
$, case, continue, coproc, getopts, select, suspend, ulimit, while: refresh page (#17687)
Refreshed $, case, continue, coproc, getopts, select, suspend, ulimit, while .md pages
1 parent 779f768 commit bf47c68

File tree

9 files changed

+21
-17
lines changed

9 files changed

+21
-17
lines changed

pages/common/$.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333

3434
- Print out a Bash array:
3535

36-
`echo ${array[@]}`
36+
`echo ${{{array_name[@]}}}`

pages/common/case.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
- Allow matching multiple patterns:
1515

16-
`case {{$ANIMAL}} in {{cat}}) echo "It's a cat" ;;& {{cat|dog}}) echo "It's a cat or a dog" ;;& *) echo "Fallback" ;; esac`
16+
`case {{$ANIMAL}} in {{cat}}) {{echo "It's a cat"}} ;;& {{cat|dog}}) {{echo "It's a cat or a dog"}} ;;& *) {{echo "Fallback"}} ;; esac`
1717

1818
- Continue to the next pattern's commands without checking the pattern:
1919

20-
`case {{$ANIMAL}} in {{cat}}) echo "It's a cat" ;& {{dog}}) echo "It's either a dog or cat fell through" ;& *) echo "Fallback" ;; esac`
20+
`case {{$ANIMAL}} in {{cat}}) echo {{"It's a cat"}} ;& {{dog}}) {{echo "It's either a dog or cat fell through"}} ;& *) {{echo "Fallback"}} ;; esac`
2121

2222
- Display help:
2323

pages/common/continue.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
66
- Skip to the next iteration:
77

8-
`while :; do continue; echo "This will never be reached"; done`
8+
`while :; do continue; {{echo "This will never be reached"}}; done`
99

1010
- Skip to the next iteration from within a nested loop:
1111

12-
`for i in {1..3}; do while :; do continue 2; done; done`
12+
`for i in {{{1..3}}}; do {{echo $i}}; while :; do continue 2; done; done`

pages/common/coproc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
- Create a coprocess which repeatedly reads `stdin` and runs some commands on the input:
2323

24-
`coproc {{name}} { while read line; do {{command1; command2; ...}}; done }`
24+
`coproc {{name}} { while read {{line}}; do {{command1; command2; ...}}; done }`
2525

2626
- Create a coprocess which repeatedly reads `stdin`, runs a pipeline on the input, and writes the output to `stdout`:
2727

28-
`coproc {{name}} { while read line; do echo "$line" | {{command1 | command2 | ...}} | cat /dev/fd/0; done }`
28+
`coproc {{name}} { while read {{line}}; do {{echo "$line"}} | {{command1 | command2 | ...}} | cat /dev/fd/0; done }`
2929

3030
- Create and use a coprocess running `bc`:
3131

pages/common/getopts.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@
44
> This command does not support longform options and thus using `getopt` is recommended instead.
55
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-getopts>.
66
7-
- Check if an option is set:
7+
- Check if an option is the first set option in the current context:
88

9-
`getopts {{x}} {{opt}}; echo $opt`
9+
`getopts {{x}} {{opt}}; echo ${{opt}}`
1010

11-
- Set an option to require an argument and check said argument:
11+
- Check if an option is set in a string (specified option must be the first element of the string):
1212

13-
`getopts {{x}}: {{opt}}; echo $OPTARG`
13+
`getopts {{x}} {{opt}} "{{string text}}"; echo ${{opt}}`
14+
15+
- Set an option to require an argument and print them:
16+
17+
`getopts {{x}}: {{opt}}; echo ${{opt}} $OPTARG`
1418

1519
- Check for multiple options:
1620

17-
`while getopts {{xyz}} {{opt}}; do case $opt in x) echo x is set;; y) echo y is set;; z) echo z is set;; esac; done`
21+
`while getopts {{xyz}} {{opt}}; do case ${{opt}} in x) {{echo x is set}};; y) {{echo y is set}};; z) {{echo z is set}};; esac; done`
1822

1923
- Set `getopts` to silent mode and handle option errors:
2024

21-
`while getopts :{{x:}} {{opt}}; do case $opt in x) ;; :) echo "Argument required";; ?) echo "Invalid argument" esac;; done`
25+
`while getopts :{{x:}} {{opt}}; do case ${{opt}} in x) ;; :) {{echo "Argument required"}};; ?) {{echo "Invalid argument"}} esac;; done`
2226

2327
- Reset `getopts`:
2428

pages/common/select.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
- Create a menu from a Bash array:
1919

20-
`{{fruits}}=({{apple orange pear banana}}); select {{word}} in ${{{fruits[@]}}}; do echo ${{word}}; done`
20+
`{{fruits}}={{(apple orange pear banana)}}; select {{word}} in ${{{fruits[@]}}}; do echo ${{word}}; done`

pages/common/suspend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
- Continue from suspension if `suspend` was used in a non-nested shell (run this in a separate terminal):
1111

12-
`pkill -CONT bash`
12+
`pkill -CONT {{bash}}`
1313

1414
- Force suspension even if this would lock you out of the system:
1515

pages/common/ulimit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
- Set max per-user process limit:
2020

21-
`ulimit -u 30`
21+
`ulimit -u {{30}}`
2222

2323
- Display help (Bash only):
2424

pages/common/while.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
- Read `stdin` and perform an action on every line:
77

8-
`while read line; do echo "$line"; done`
8+
`while read line; do {{echo "$line"}}; done`
99

1010
- Execute a command forever once every second:
1111

0 commit comments

Comments
 (0)