Skip to content

Commit

Permalink
tests: Move inplace sed to helpers.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Oct 31, 2024
1 parent f3a68ee commit 7cb88db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions tests/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <expression> 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
14 changes: 0 additions & 14 deletions tests/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <expression> 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}")
Expand Down

0 comments on commit 7cb88db

Please sign in to comment.