test/system: Avoid conditionals only supported by Bash's built-in 'test'
The '[' and 'test' implementations from GNU coreutils don't support '-v'
as a way to check if a shell variable is set [1]. Only Bash's built-in
implementations do.
This is quite confusing and makes it difficult to find out what '-v'
actually does. eg., 'man --all test' only shows the manual for the GNU
coreutils version, which doesn't list '-v' [1], and, 'man --all [' only
shows the manual for Bash's built-ins, which also doesn't list '-v'.
One has to go to the bash(1) manual to find it [2].
Elsewhere in the code base [3], the same thing is accomplished with '-z'
and parameter substitution, which are more widely supported and, hence,
easier to find documentation for.
[1] https://manpages.debian.org/testing/coreutils/test.1.en.html
[2] https://linux.die.net/man/1/bash
[3] Commit 84ae385f33
https://github.com/containers/toolbox/pull/1334
https://github.com/containers/toolbox/pull/1341
This commit is contained in:
parent
21299a3c5b
commit
341ae55f9d
1 changed files with 2 additions and 2 deletions
|
@ -86,7 +86,7 @@ function _pull_and_cache_distro_image() {
|
||||||
distro="$1"
|
distro="$1"
|
||||||
version="$2"
|
version="$2"
|
||||||
|
|
||||||
if ! [ -v IMAGES[$distro] ]; then
|
if [ -z "${IMAGES[$distro]+x}" ]; then
|
||||||
fail "Requested distro (${distro}) does not have a matching image"
|
fail "Requested distro (${distro}) does not have a matching image"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ function pull_distro_image() {
|
||||||
distro="$1"
|
distro="$1"
|
||||||
version="$2"
|
version="$2"
|
||||||
|
|
||||||
if ! [ -v IMAGES[$distro] ]; then
|
if [ -z "${IMAGES[$distro]+x}" ]; then
|
||||||
fail "Requested distro (${distro}) does not have a matching image"
|
fail "Requested distro (${distro}) does not have a matching image"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue