-
Notifications
You must be signed in to change notification settings - Fork 53
/
get_bash5_macos.sh
executable file
·47 lines (39 loc) · 1.33 KB
/
get_bash5_macos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
#
# Only required for macos for unit testing advanced bash 4+ functionality and for bats.
#
# Our hack for macos bash version too old for unit testing
# was in .travis.yml
# brew update takes very long time
# according to https://docs.travis-ci.com/user/reference/osx#homebrew
# homebrew is already updated, but it's still really slow
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bash; fi
pathshow ()
{
local var=${1:-PATH};
eval "echo \$$var | tr : $'\n'"
}
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
if ((BASH_VERSINFO[0] <= 3)) ; then
# The following hack kept a bash5 binary in our repository
# only for our speedup pupose.
# we simply install it
bash_bin=/usr/local/bin/bash
gzip -dc ./bash-5.0.16_x86_64-apple-darwin17.7.0.gz | \
sudo bash -c "cat > $bash_bin && chmod a+x $bash_bin"
fi
fi
echo "======================= splited PATH"
pathshow PATH
echo "======================= new bash version"
hash -r bash
bash --version
type bash
# require sed macos comaptible regexp \+ doesn't exist ==> \{1,\}
MY_BASH_VERSINFO=$(bash --version | sed -n -e '1 s/^.*version \([0-9.]\{1,\}\).*/\1/ p')
if [[ ! $MY_BASH_VERSINFO =~ ^[4-9] ]] ; then
echo "install bash5 failed"
# ./travis/reverse_ssh_tunnel.sh
exit 1
fi