Fix python_setup/install_tool.sh when python2 not present#997
Merged
edoardopirovano merged 2 commits intogithub:mainfrom Mar 29, 2022
cdivitotawela:python2-fix
Merged
Fix python_setup/install_tool.sh when python2 not present#997edoardopirovano merged 2 commits intogithub:mainfrom cdivitotawela:python2-fix
python2 not present#997edoardopirovano merged 2 commits intogithub:mainfrom
cdivitotawela:python2-fix
Conversation
RasmusWL
approved these changes
Mar 25, 2022
Member
There was a problem hiding this comment.
Thanks. I guess I did not confirm that the command -v worked as intended back then. I have been able to reproduce with the code below (on Ubuntu 21.10)
#!/bin/sh
if command -v nonexistingcommand &> /dev/null; then
echo "old true"
else
echo "old false"
fi
if command -v nonexistingcommand > /dev/null 2>&1; then
echo "new true"
else
echo "new false"
fiwhich outputs
old true
new false
I can't say I fully understand this (in particular what the old version actually did), but thanks for the fix 💪
python2 not present
When the script executed on a runner which does not have python2, script incorrectly execute the code inside the if condition. This script runs using /bin/sh in Ubuntu and cause the problem. Fix for this issue to use different syntax in output redirection. Issue is reproduced using running the job on ubunutu container. Fix also verified in the action https://github.com/cdivitotawela/codeql-issue/actions/runs/2038007502
edoardopirovano
approved these changes
Mar 29, 2022
Contributor
edoardopirovano
left a comment
There was a problem hiding this comment.
Looks good to me too, thanks for the fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #996
When the script executed on a runner which does not have python2, script incorrectly execute the code inside the if condition. This script runs using /bin/sh in Ubuntu and cause the problem. Fix for this issue to use different syntax in output redirection.
Issue is reproduced using running the job on Ubuntu container. Fix also verified in the action https://github.com/cdivitotawela/codeql-issue/actions/runs/2038530172
Tested using action file https://github.com/cdivitotawela/codeql-issue/blob/main/.github/workflows/investigate.yaml
Merge / deployment checklist