mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Dogfooding the examples spots SC2250, SC2292
12
SC2312.md
12
SC2312.md
@@ -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:
|
||||
|
Reference in New Issue
Block a user