Dogfooding the examples spots SC2250, SC2292

habere-et-dispertire
2022-03-19 11:14:22 +00:00
parent afbbee7882
commit b43e35abed

@@ -7,7 +7,7 @@ This is an optional suggestion enabled with `shellcheck -o check-extra-masked-re
```sh
set -e
cd "$(get_chroot_dir)/etc"
tar xf "$config"
tar xf "${config}"
```
### Correct code:
@@ -15,8 +15,8 @@ tar xf "$config"
```sh
set -e
dir="$(get_chroot_dir)"
cd "$dir/etc"
tar xf "$config"
cd "${dir}/etc"
tar xf "${config}"
```
### Correct code: (with correction)
@@ -24,9 +24,9 @@ tar xf "$config"
```sh
set -e
dir="$(get_chroot_dir)"
[ -d "${dir}" ] || exit 1
cd "$dir/etc"
tar xf "$config"
[[ -d "${dir}" ]] || exit 1
cd "${dir}/etc"
tar xf "${config}"
```
### Rationale: