CrowdStrike / falcon-scripts

Scripts to streamline the deployment and use of the CrowdStrike Falcon sensor
The Unlicense
142 stars 83 forks source link

Update curl version logic #175

Closed carlosmmatos closed 1 year ago

carlosmmatos commented 1 year ago

Fixes #174

This PR enhances the logic used to test for curl version compatability.

redhatrises commented 1 year ago

I wonder if sort -V or something like https://apple.stackexchange.com/questions/83939/compare-multi-digit-version-numbers-in-bash/123408#123408 would be better.

ffalor commented 1 year ago

Approved before I saw gabes comment. Changes LGTM, but I'll let you two decide what to do with that :)

carlosmmatos commented 1 year ago

I wonder if sort -V or something like https://apple.stackexchange.com/questions/83939/compare-multi-digit-version-numbers-in-bash/123408#123408 would be better.

I went through a few different iterations.. each time stumbling upon the misery of supporting bash and dash lol... what I have here is easily readable and works for both.

The sort -V is an interesting approach - however I'm not sure how readable it is or if -V and -C options are supported on all versions lol..

carlosmmatos commented 1 year ago

@redhatrises This is what sort -V -C approach would look like:

old_curl=$(
    version=$(curl --version | head -n 1 | awk '{ print $2 }')
    minimum="7.55"

    # Check if the version is less than the minimum
    if echo -e "$version\n$minimum" | sort -V -C; then
        echo 0
    else
        echo 1
    fi
)

Other than the comment.. I wouldn't know wth is going on lol. What do you think?

carlosmmatos commented 1 year ago

@redhatrises code has been updated to work with sort as well as bash/dash