Created
April 10, 2016 22:47
-
-
Save sahal/6939db90e9fecdc0c8bc60edc4fcf160 to your computer and use it in GitHub Desktop.
figure out python version
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
| #!/bin/bash | |
| # basic launcher | |
| set -e | |
| set -u | |
| python_path="$(which python)" | |
| #python_path="/usr/bin/python" | |
| # figure out python version (might be useful in the future) | |
| python_version=$($python_path --version 2>&1) | |
| python_2_str="^Python 2" | |
| python_3_str="^Python 3" | |
| if [[ $python_version =~ $python_3_str ]]; then | |
| echo "Python 3 found!" | |
| elif [[ $python_version =~ $python_2_str ]];then | |
| echo "Python 2 found!" | |
| else | |
| echo "Unknown version of Python found, please set \$python_path" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment