diff --git a/pages/common/$.md b/pages/common/$.md index 2b1a8074de..b743c00334 100644 --- a/pages/common/$.md +++ b/pages/common/$.md @@ -33,4 +33,4 @@ - Print out a Bash array: -`echo ${array[@]}` +`echo ${{{array_name[@]}}}` diff --git a/pages/common/case.md b/pages/common/case.md index 6113198d28..75d6aa677a 100644 --- a/pages/common/case.md +++ b/pages/common/case.md @@ -13,11 +13,11 @@ - Allow matching multiple patterns: -`case {{$ANIMAL}} in {{cat}}) echo "It's a cat" ;;& {{cat|dog}}) echo "It's a cat or a dog" ;;& *) echo "Fallback" ;; esac` +`case {{$ANIMAL}} in {{cat}}) {{echo "It's a cat"}} ;;& {{cat|dog}}) {{echo "It's a cat or a dog"}} ;;& *) {{echo "Fallback"}} ;; esac` - Continue to the next pattern's commands without checking the pattern: -`case {{$ANIMAL}} in {{cat}}) echo "It's a cat" ;& {{dog}}) echo "It's either a dog or cat fell through" ;& *) echo "Fallback" ;; esac` +`case {{$ANIMAL}} in {{cat}}) echo {{"It's a cat"}} ;& {{dog}}) {{echo "It's either a dog or cat fell through"}} ;& *) {{echo "Fallback"}} ;; esac` - Display help: diff --git a/pages/common/continue.md b/pages/common/continue.md index b889effc79..46faca8baa 100644 --- a/pages/common/continue.md +++ b/pages/common/continue.md @@ -5,8 +5,8 @@ - Skip to the next iteration: -`while :; do continue; echo "This will never be reached"; done` +`while :; do continue; {{echo "This will never be reached"}}; done` - Skip to the next iteration from within a nested loop: -`for i in {1..3}; do while :; do continue 2; done; done` +`for i in {{{1..3}}}; do {{echo $i}}; while :; do continue 2; done; done` diff --git a/pages/common/coproc.md b/pages/common/coproc.md index 9dd9563a2a..967a1ffdc9 100644 --- a/pages/common/coproc.md +++ b/pages/common/coproc.md @@ -21,11 +21,11 @@ - Create a coprocess which repeatedly reads `stdin` and runs some commands on the input: -`coproc {{name}} { while read line; do {{command1; command2; ...}}; done }` +`coproc {{name}} { while read {{line}}; do {{command1; command2; ...}}; done }` - Create a coprocess which repeatedly reads `stdin`, runs a pipeline on the input, and writes the output to `stdout`: -`coproc {{name}} { while read line; do echo "$line" | {{command1 | command2 | ...}} | cat /dev/fd/0; done }` +`coproc {{name}} { while read {{line}}; do {{echo "$line"}} | {{command1 | command2 | ...}} | cat /dev/fd/0; done }` - Create and use a coprocess running `bc`: diff --git a/pages/common/getopts.md b/pages/common/getopts.md index 4cccb600c7..fc055c0e3f 100644 --- a/pages/common/getopts.md +++ b/pages/common/getopts.md @@ -4,21 +4,25 @@ > This command does not support longform options and thus using `getopt` is recommended instead. > More information: . -- Check if an option is set: +- Check if an option is the first set option in the current context: -`getopts {{x}} {{opt}}; echo $opt` +`getopts {{x}} {{opt}}; echo ${{opt}}` -- Set an option to require an argument and check said argument: +- Check if an option is set in a string (specified option must be the first element of the string): -`getopts {{x}}: {{opt}}; echo $OPTARG` +`getopts {{x}} {{opt}} "{{string text}}"; echo ${{opt}}` + +- Set an option to require an argument and print them: + +`getopts {{x}}: {{opt}}; echo ${{opt}} $OPTARG` - Check for multiple options: -`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` +`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` - Set `getopts` to silent mode and handle option errors: -`while getopts :{{x:}} {{opt}}; do case $opt in x) ;; :) echo "Argument required";; ?) echo "Invalid argument" esac;; done` +`while getopts :{{x:}} {{opt}}; do case ${{opt}} in x) ;; :) {{echo "Argument required"}};; ?) {{echo "Invalid argument"}} esac;; done` - Reset `getopts`: diff --git a/pages/common/select.md b/pages/common/select.md index 218b5ecb83..b772ec0048 100644 --- a/pages/common/select.md +++ b/pages/common/select.md @@ -17,4 +17,4 @@ - Create a menu from a Bash array: -`{{fruits}}=({{apple orange pear banana}}); select {{word}} in ${{{fruits[@]}}}; do echo ${{word}}; done` +`{{fruits}}={{(apple orange pear banana)}}; select {{word}} in ${{{fruits[@]}}}; do echo ${{word}}; done` diff --git a/pages/common/suspend.md b/pages/common/suspend.md index 5d79213b3f..38926a7fbf 100644 --- a/pages/common/suspend.md +++ b/pages/common/suspend.md @@ -9,7 +9,7 @@ - Continue from suspension if `suspend` was used in a non-nested shell (run this in a separate terminal): -`pkill -CONT bash` +`pkill -CONT {{bash}}` - Force suspension even if this would lock you out of the system: diff --git a/pages/common/ulimit.md b/pages/common/ulimit.md index 23d663895e..bc72abf502 100644 --- a/pages/common/ulimit.md +++ b/pages/common/ulimit.md @@ -18,7 +18,7 @@ - Set max per-user process limit: -`ulimit -u 30` +`ulimit -u {{30}}` - Display help (Bash only): diff --git a/pages/common/while.md b/pages/common/while.md index cb39b2e297..905a99ffcc 100644 --- a/pages/common/while.md +++ b/pages/common/while.md @@ -5,7 +5,7 @@ - Read `stdin` and perform an action on every line: -`while read line; do echo "$line"; done` +`while read line; do {{echo "$line"}}; done` - Execute a command forever once every second: