...
 
Commits (4)
#!/bin/sh
# Discarding and considering return values.
workdir="/i_probably_do_no_exist"
# Discarding return values.
cd "$workdir"
# Considering return values using `$?`.
cd "$workdir"
rv=$?
echo "Info: Changing to \"$workdir\" returned rv=$rv"
# Considering return values using boolean operator.
cd "$workdir" || echo "Warning: Could not change to \"$workdir\"."
# Considering return values using if-else.
if cd "$workdir" ; then
echo "Info: Changed to \"$workdir\"."
else
echo "Error: Could not change to \"$workdir\"."
fi
# Crashing on failed commands with `set -e`.
set -e
cd "$workdir"
......@@ -15,11 +15,13 @@ Table of Contents
Example for assignment of values.
* 1.5 [Quoting](./01-basics/5-quoting.sh)
Example for here-documents using shell quoting mechanisms.
* 1.6 [Shell Options](./01-basics/6-shell-options.sh)
Setting shell options using shebang commandline or `set`.
* 1.7 [Bash-only Options](./01-basics/7-bash--only-options.bash)
* 1.6 [Return Values](./01-basics/6-return-values.sh)
Discarding and considering return values.
* 1.7 [Shell Options](./01-basics/7-shell-options.sh)
Example of setting shell options using shebang commandline or set command.
* 1.8 [Bash-only Options](./01-basics/8-bash--only-options.bash)
Setting Bash-only options with `shopt`.
* 1.8 [Exercises](./01-basics/8-exercises.md)
* 1.9 [Exercises](./01-basics/9-exercises.md)
### 2 [Sourcing](./02-sourcing/)
* 2.1 [Dynamic Sourcing](./02-sourcing/1-dynamic-sourcing.sh)
......