Updated SC2312 (markdown)

TinCanTech
2022-01-07 18:05:41 +00:00
parent baff7d4b10
commit a555746471

@@ -18,6 +18,17 @@ dir="$(get_chroot_dir)"
cd "$dir/etc"
tar xf "$config"
```
### Correct code: (with correction)
```sh
set -e
dir="$(get_chroot_dir)"
[ -d "${dir}" ] || exit 1
cd "$dir/etc"
tar xf "$config"
```
### Rationale:
In the problematic example, the exit code for `get_chroot_dir` is ignored because it is used in a command substitution in the argument of another command.