From 9e2a0463e55b85af85b29cca6f534c9d7a15633a Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 7 Feb 2022 09:44:27 -0800 Subject: [PATCH] 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 --- tests/integration/helpers.bash | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index de6bf7050..91cd9967c 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -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