From 7cb88dbf1d66b25f9f0b1d5fd8ce6c247824f416 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 30 Oct 2024 17:49:22 +0100 Subject: [PATCH] tests: Move inplace sed to helpers.sh Signed-off-by: Jakub Jelen --- tests/helpers.sh | 14 ++++++++++++++ tests/setup.sh | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/helpers.sh b/tests/helpers.sh index 6fc1f2cb..7883b759 100755 --- a/tests/helpers.sh +++ b/tests/helpers.sh @@ -72,3 +72,17 @@ kill_children() { # make sure it is killed before we continue jobs -p | xargs -r kill -9 || true } + +# macOS uses BSD sed, which expects the argument after -i (with a space after +# it!) to be the backup suffix, while GNU sed expects a potential backup suffix +# directly after -i and interprets -i as in-place editing with no +# backup. +# +# Use "${sed_inplace[@]}" to make that work transparently by setting it to the +# arguments required to achieve in-place editing without backups depending on +# the version of sed. +if sed --version 2>/dev/null | grep -q 'GNU sed'; then + export sed_inplace=("-i") +else + export sed_inplace=("-i" "") +fi diff --git a/tests/setup.sh b/tests/setup.sh index 255164da..1435bebe 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -57,20 +57,6 @@ if [ -z "$certtool" ]; then exit 0 fi -# macOS uses BSD sed, which expects the argument after -i (with a space after -# it!) to be the backup suffix, while GNU sed expects a potential backup suffix -# directly after -i and interprets -i as in-place editing with no -# backup. -# -# Use "${sed_inplace[@]}" to make that work transparently by setting it to the -# arguments required to achieve in-place editing without backups depending on -# the version of sed. -if sed --version 2>/dev/null | grep -q 'GNU sed'; then - sed_inplace=("-i") -else - sed_inplace=("-i" "") -fi - # NSS uses the second slot for certificates, so we need to provide the token # label in the args to allow pkcs11-tool to find the right slot P11DEFARGS=("--module=${P11LIB}" "--login" "--pin=${PINVALUE}" "--token-label=${TOKENLABEL}")