Skip to content

Commit ae48f20

Browse files
committed
fixup! chore: add version checks to lib.sh
1 parent 173031f commit ae48f20

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/lib.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,17 @@ error() {
111111
exit 1
112112
}
113113

114+
# isdarwin returns an error if the current platform is not darwin.
115+
isdarwin() {
116+
[[ "${OSTYPE:-darwin}" == *darwin* ]]
117+
}
118+
114119
libsh_bad_dependencies=0
115120

116121
if ((BASH_VERSINFO[0] < 4)); then
117122
libsh_bad_dependencies=1
118123
log "ERROR: You need at least bash 4.0 to run the scripts in the Coder repo."
119-
if [[ "${OSTYPE:-darwin}" == "darwin" ]]; then
124+
if isdarwin; then
120125
log "On darwin:"
121126
log "- brew install bash"
122127
log "- Restart your terminal"
@@ -128,7 +133,7 @@ fi
128133
if [[ "$(getopt --version)" == *--* ]]; then
129134
libsh_bad_dependencies=1
130135
log "ERROR: You need GNU getopt to run the scripts in the Coder repo."
131-
if [[ "${OSTYPE:-darwin}" == "darwin" ]]; then
136+
if isdarwin; then
132137
log "On darwin:"
133138
log "- brew install gnu-getopt"
134139
# shellcheck disable=SC2016
@@ -146,7 +151,7 @@ make_version="$(make --version 2>/dev/null | head -n1 | grep -oE '([[:digit:]]+\
146151
if [ "${make_version//.*/}" -lt 4 ]; then
147152
libsh_bad_dependencies=1
148153
log "ERROR: You need at least make 4.0 to run the scripts in the Coder repo."
149-
if [[ "${OSTYPE:-darwin}" == "darwin" ]]; then
154+
if isdarwin; then
150155
log "On darwin:"
151156
log "- brew install make"
152157
# shellcheck disable=SC2016

0 commit comments

Comments
 (0)