@@ -110,3 +110,52 @@ error() {
110
110
log " ERROR: $* "
111
111
exit 1
112
112
}
113
+
114
+ libsh_bad_dependencies=0
115
+
116
+ if (( BASH_VERSINFO[0 ] < 4 )) ; then
117
+ libsh_bad_dependencies=1
118
+ log " ERROR: You need at least bash 4.0 to run the scripts in the Coder repo."
119
+ if [[ " ${OSTYPE:- darwin} " == " darwin" ]]; then
120
+ log " On darwin:"
121
+ log " - brew install bash"
122
+ log " - Restart your terminal"
123
+ fi
124
+ log
125
+ fi
126
+
127
+ # BSD getopt (which is installed by default on Macs) is not supported.
128
+ if [[ " $( getopt --version) " == * --* ]]; then
129
+ libsh_bad_dependencies=1
130
+ log " ERROR: You need GNU getopt to run the scripts in the Coder repo."
131
+ if [[ " ${OSTYPE:- darwin} " == " darwin" ]]; then
132
+ log " On darwin:"
133
+ log " - brew install gnu-getopt"
134
+ # shellcheck disable=SC2016
135
+ log ' - Add "$(brew --prefix)/opt/gnu-getopt/bin" to your PATH'
136
+ log " - Restart your terminal"
137
+ fi
138
+ log
139
+ fi
140
+
141
+ # The bash scripts don't call Make directly, but we want to make (ha ha) sure
142
+ # that make supports the features the repo uses. Notably, Macs have an old
143
+ # version of Make installed out of the box that doesn't support new features
144
+ # like ONESHELL.
145
+ make_version=" $( make --version 2> /dev/null | head -n1 | grep -oE ' ([[:digit:]]+\.){1,2}[[:digit:]]+' ) "
146
+ if [ " ${make_version// .*/ } " -lt 4 ]; then
147
+ libsh_bad_dependencies=1
148
+ log " ERROR: You need at least make 4.0 to run the scripts in the Coder repo."
149
+ if [[ " ${OSTYPE:- darwin} " == " darwin" ]]; then
150
+ log " On darwin:"
151
+ log " - brew install make"
152
+ # shellcheck disable=SC2016
153
+ log ' - Add "$(brew --prefix)/opt/make/libexec/gnubin" to your PATH (you should Google this first)'
154
+ log " - Restart your terminal"
155
+ fi
156
+ log
157
+ fi
158
+
159
+ if [[ " $libsh_bad_dependencies " == 1 ]]; then
160
+ error " Invalid dependencies, see above for more details."
161
+ fi
0 commit comments