From cb0de97bc3b6306c36e30359e7e7ac8000888c9d Mon Sep 17 00:00:00 2001 From: "Krystian G." <108719245+krysgor@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:15:54 +0200 Subject: [PATCH] fix: capture-snippet.sh can handle leading whitespaces now (#3249) (#3250) Signed-off-by: Gorny Krystian Co-authored-by: Gorny Krystian --- syft/pkg/cataloger/binary/test-fixtures/capture-snippet.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/syft/pkg/cataloger/binary/test-fixtures/capture-snippet.sh b/syft/pkg/cataloger/binary/test-fixtures/capture-snippet.sh index 2c7fb063e..088776f48 100755 --- a/syft/pkg/cataloger/binary/test-fixtures/capture-snippet.sh +++ b/syft/pkg/cataloger/binary/test-fixtures/capture-snippet.sh @@ -69,6 +69,11 @@ if ! command -v xxd &> /dev/null; then exit 1 fi +# check if xargs is even installed +if ! command -v xargs &> /dev/null; then + echo "xargs not found. Please install xargs." + exit 1 +fi PATTERN=${SEARCH_FOR:-$VERSION} @@ -116,7 +121,7 @@ while $CONTINUE_LOOP; do fi # search for the pattern in the binary file and capture the offset - OFFSET=$(echo "${SELECTED_RESULT}" | cut -d ' ' -f 1) + OFFSET=$(echo "${SELECTED_RESULT}" | xargs | cut -d ' ' -f 1) if [ -z "$OFFSET" ]; then echo "Pattern not found."