-
Notifications
You must be signed in to change notification settings - Fork 0
/
os.sh
44 lines (40 loc) · 740 Bytes
/
os.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
import "string@0.1.0"
os_platform() {
local platform
platform="$(uname -s | string_lower)"
if string_starts_with "$platform" "mingw"; then
platform="windows"
fi
echo "$platform"
}
os_arch() {
local arch
arch="$(uname -m)"
echo "$arch"
}
os_path_push() {
local dir="$1"
local IFS=:
local sep=
local path=
for p in $PATH; do
if [ -n "$p" ] && [ "$p" != "$dir" ]; then
path="${path}${sep}${p}"
sep=:
fi
done
export PATH="${path}${sep}${dir}"
}
os_path_unshift() {
local dir="$1"
local IFS=:
local sep=
local path=
for p in $PATH; do
if [ -n "$p" ] && [ "$p" != "$dir" ]; then
path="${path}${sep}${p}"
sep=:
fi
done
export PATH="${dir}${sep}${path}"
}