Skip to content

Commit

Permalink
Don't declare a function for bash check
Browse files Browse the repository at this point in the history
  • Loading branch information
ocaisa committed Jul 29, 2024
1 parent 6f43f13 commit 47c0a34
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions init/eessi_archdetect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

# Confirm the current shell is Bash >= 4
# (works for sh, bash, dash, zsh, ksh, but not fish, tcsh, elvish)
check_bash() {
if [ -n "$BASH_VERSION" ]; then
# Extract the major version numbers
bash_version=$(echo "$BASH_VERSION" | grep -oP '^\d+\.\d+')
major_version=$(echo "$bash_version" | cut -d. -f1)

# Check if the major version is 4 or higher
if [ "$major_version" -ge 4 ]; then
return 0
else
echo "Error: This script must be run with Bash > 4, you have $BASH_VERSION." >&2
exit 1
fi
if [ -n "$BASH_VERSION" ]; then
# Extract the major version numbers
bash_version=$(echo "$BASH_VERSION" | grep -oP '^\d+\.\d+')
major_version=$(echo "$bash_version" | cut -d. -f1)

# Check if the major version is 4 or higher
if [ "$major_version" -ge 4 ]; then
return 0
else
echo "Error: This script must be run with Bash." >&2
echo "Error: This script must be run with Bash > 4, you have $BASH_VERSION." >&2
exit 1
fi
}
check_bash
else
echo "Error: This script must be run with Bash." >&2
exit 1
fi

VERSION="1.1.0"

Expand Down

0 comments on commit 47c0a34

Please sign in to comment.