-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgnu-install.sh
More file actions
executable file
·58 lines (53 loc) · 1.27 KB
/
gnu-install.sh
File metadata and controls
executable file
·58 lines (53 loc) · 1.27 KB
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
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
###
### Script to install GNU tools (typically on macOS).
###
### Requires `brew` to be installed.
###
set -o errexit # abort on nonzero exit status
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
### GNU Tools to install
###
### References:
### - https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da
### - https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
### https://github.com/asantra1/macOS-gnu-tools/blob/master/gnu-cmd.sh
declare -a GNU_TOOLS=(
"binutils"
"coreutils"
"diffutils"
"ed"
"findutils"
"gawk"
"gnu-indent"
"gnu-sed"
"gnu-tar"
"gnu-which"
"gnutls"
"grep"
"gzip"
"screen"
"watch"
"wdiff"
"wget"
)
### Validate `brew` is installed
if ! command -v brew &>/dev/null; then
echo "Error: 'brew' is required. Please install it first."
exit 1
fi
### Install GNU Tools
for tool in "${GNU_TOOLS[@]}"; do
if brew list --formula | grep -q "^${tool}\$"; then
if brew outdated --formula | grep -q "^${tool}\$"; then
echo "Updating ${tool}..."
brew upgrade "${tool}"
else
echo "${tool} is already installed and up-to-date."
fi
else
echo "Installing ${tool}..."
brew install "${tool}"
fi
done