forked from bashtools/JSONPath.sh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathensure_deps.sh
executable file
·44 lines (34 loc) · 992 Bytes
/
ensure_deps.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
#!/usr/bin/env bash
set -euo pipefail
is_osx() {
test "$(uname -s)" == "Darwin"
}
test_gnu_compat() {
local error=0
if ! seq 0 -1 1 &> /dev/null; then
error=1
>&2 echo "Make sure you have GNU coreutils installed"
fi
if grep --version | grep 'BSD' &> /dev/null; then
error=1
>&2 echo "Make sure you have GNU grep or compatible installed"
fi
if ! sed --version &> /dev/null; then
error=1
>&2 echo "Make sure you have GNU sed or compatible installed"
fi
if [[ $error -gt 0 && is_osx ]]; then
>&2 echo "With homebrew you may install necessary deps via \`brew install grep gnu-sed coreutils\`"
fi
return $error
}
main() {
if is_osx; then
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
fi
test_gnu_compat
"$@"
}
main "$@"