Skip to content

Commit

Permalink
fix: capture-snippet.sh can handle leading whitespaces now (#3249) (#…
Browse files Browse the repository at this point in the history
…3250)

Signed-off-by: Gorny Krystian <[email protected]>
Co-authored-by: Gorny Krystian <[email protected]>
  • Loading branch information
krysgor and Gorny Krystian authored Sep 19, 2024
1 parent 50016c3 commit cb0de97
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion syft/pkg/cataloger/binary/test-fixtures/capture-snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit cb0de97

Please sign in to comment.