Skip to content

Commit

Permalink
fix(header): [#307] rewrite bash checking method and reduce required …
Browse files Browse the repository at this point in the history
…bash version
  • Loading branch information
patrick330602 committed Apr 10, 2024
1 parent 399dfe4 commit 4ead018
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/wslu-header
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ fi
# prevent bash -x
set +x

bash_version_major=$(echo "$BASH_VERSION" | cut -d'.' -f1)
bash_version_full=$(bash --version | head -n 1)
bash_version_major=$(echo "$bash_version_full" | cut -d ' ' -f 4 | cut -d '.' -f 1)
bash_version_minor=$(echo "$bash_version_full" | cut -d ' ' -f 4 | cut -d '.' -f 2)

# pipeline content to pipe... if it is wslclip
if [[ "$wslu_util_name" == "wslclip" ]]; then
Expand Down Expand Up @@ -152,11 +154,12 @@ function error_echo {
exit "$2"
}

# Check if the major version number is greater than 5
if [ "$(expr "$bash_version_major" \>= 5)" -ne 1 ]; then
error_echo "You should use Bash 5 and higher; exiting." 1
# Check if the version number of bash is greater or equal to 4.4
if [ "$bash_version_major" -lt 4 ] || { [ "$bash_version_major" -eq 4 ] && [ "$bash_version_minor" -lt 4 ]; }; then
error_echo "Bash version is too old. Please upgrade to 4.4 or later." 1
fi


# source default config
if [ -f "${wslu_dest_dir}${wslu_prefix}/share/wslu/conf" ]; then
debug_echo "source default setting"
Expand Down

0 comments on commit 4ead018

Please sign in to comment.