tests/int: fix runc_spec for set -u

Older bash versions treats variable as unset if nothing has been
assigned to it. Here is an example from CentOS 7 system:

	[kir@localhost ~]$ bash -u -c 'x() { local args=(); echo "${args[@]}"; }; x'
	bash: args[@]: unbound variable
	[kir@localhost ~]$ echo $BASH_VERSION
	4.2.46(2)-release

Rewrite to work around this.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2022-02-07 09:44:27 -08:00
parent ad93b0c6c9
commit 9e2a0463e5
+3 -5
View File
@@ -59,12 +59,10 @@ function __runc() {
# Wrapper for runc spec.
function runc_spec() {
local args=()
if [ "$ROOTLESS" -ne 0 ]; then
args+=("--rootless")
fi
local rootless=""
[ "$ROOTLESS" -ne 0 ] && rootless="--rootless"
runc spec "${args[@]}"
runc spec $rootless
# Always add additional mappings if we have idmaps.
if [[ "$ROOTLESS" -ne 0 ]] && [[ "$ROOTLESS_FEATURES" == *"idmap"* ]]; then