From 638422e113805c4c45547657dff328140785b77e Mon Sep 17 00:00:00 2001 From: Thomas Woerner Date: Thu, 17 Apr 2025 16:10:10 +0200 Subject: [PATCH] infra/image/shcontainer: Fix processing of multi item CAP_DEFAULTS readarray expects to get an item per line to be added to the array. Printing one item per line with printf fixes this to get the proper formatting for "${CAP_DEFAULTS[@]}" as a valid input for readarray. --- infra/image/shcontainer | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infra/image/shcontainer b/infra/image/shcontainer index 018fac8c..3b6c4968 100644 --- a/infra/image/shcontainer +++ b/infra/image/shcontainer @@ -4,6 +4,7 @@ SCRIPTDIR="$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")")" TOPDIR="$(readlink -f "${SCRIPTDIR}/../..")" +# shellcheck disable=SC1091 . "${SCRIPTDIR}/shdefaults" # shellcheck disable=SC1091 @@ -15,7 +16,8 @@ container_create() { shift 2 declare -a extra_opts readarray -t extra_opts < \ - <(sed -e "s/-/--cap-drop=/g" -e "s/+/--cap-add=/g" <<< "${CAP_DEFAULTS[@]}") + <(sed -e "s/-/--cap-drop=/g" -e "s/+/--cap-add=/g" \ + <<< "$(printf '%s\n' "${CAP_DEFAULTS[@]}")") for opt in "$@" do [ -z "${opt}" ] && continue