Created
November 11, 2020 09:42
-
-
Save mickdekkers/8dc68f12fb13bd62a408dabbe93bb813 to your computer and use it in GitHub Desktop.
Bash snippet to require bash version >= 4
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
#!/usr/bin/env bash | |
if [[ $BASH_VERSION == [0123].* ]]; then | |
>&2 printf "\033[0;31mThe %s script requires bash >= v4 (released february 2009)\033[0m\n" "$0" | |
>&2 echo "You are using bash $BASH_VERSION" | |
if [[ "$(uname -s)" == Darwin* ]]; then | |
>&2 echo "macOS is known to include a particularly ancient version of bash due to licensing shenanigans." | |
>&2 printf "You can use homebrew to update it yourself: \033[1;36mbrew install bash \033[0m\n" | |
fi | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment