File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,34 @@ function load_env_vars() {
26
26
fi
27
27
}
28
28
29
+ # Check if Bash version meets the minimum requirement
30
+ function check_bash_version() {
31
+ local required_version=$1
32
+ local bash_version
33
+ bash_version=$( bash --version | head -n1 | awk ' {print $4}' | sed ' s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/' )
34
+
35
+ if [[ $bash_version =~ ^([0-9]+)\. ([0-9]+)\. ([0-9]+) ]]; then
36
+ local major=${BASH_REMATCH[1]}
37
+ local minor=${BASH_REMATCH[2]}
38
+ local patch=${BASH_REMATCH[3]}
39
+
40
+ IFS=' .' read -r -a required_parts <<< " $required_version"
41
+ local required_major=${required_parts[0]}
42
+ local required_minor=${required_parts[1]}
43
+ local required_patch=${required_parts[2]}
44
+
45
+ if (( major > required_major || (\
46
+ major == required_major && minor > required_minor) || (\
47
+ major == required_major && minor == required_minor && patch >= required_patch)) ); then
48
+ return 0
49
+ else
50
+ return 1
51
+ fi
52
+ else
53
+ return 1
54
+ fi
55
+ }
56
+
29
57
# Check if a command is installed
30
58
function check_command() {
31
59
local command=" $1 "
Original file line number Diff line number Diff line change @@ -9,6 +9,20 @@ function main() {
9
9
# Check if required commands are installed
10
10
check_command " jq"
11
11
check_command " bash"
12
+ check_command " brew"
13
+
14
+ # Set the required Bash version
15
+ local required_bash_version=" 4.0.0"
16
+
17
+ # Check Bash version and proceed with installation if necessary
18
+ if check_bash_version " $required_bash_version " ; then
19
+ echo " Bash version meets the minimum requirement (>= $required_bash_version ). Skipping installation."
20
+ else
21
+ echo " Bash version does not meet the minimum requirement (>= $required_bash_version ). Proceeding with installation using Homebrew..."
22
+ # Add your Homebrew installation commands here
23
+ brew update
24
+ brew install bash
25
+ fi
12
26
13
27
# Check if the problem title-slug or URL is provided
14
28
if [ " $# " -eq 1 ]; then
You can’t perform that action at this time.
0 commit comments