-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_lib.sh
executable file
·58 lines (53 loc) · 1.11 KB
/
_lib.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
if [ "${SILENT:-0}" != "1" ]; then
set -uxe
fi
has_command() {
command -v "$1" 2> /dev/null 1>&2
echo "$?"
}
if [ "$(has_command curl)" -eq "0" ]; then
__fetch="curl -Ls"
elif [ "$(has_command wget)" -eq "0" ]; then
__fetch="wget -O -"
else
echo curlかwgetをインストールして再実行してください
exit 1
fi
fetch() {
$__fetch "$*"
}
git_pull_or_clone() {
cd="$(pwd)"
if [ -d "$2" ]; then
if [ "${SKIP_UPDATE:-0}" != "1" ]; then
cd "$2"
git reset --hard
git pull
fi
else
git clone "$1" "$2"
fi
cd "$2"
if [ "${SKIP_UPDATE:-0}" != "1" ]; then
git submodule update --init --recursive -j 9
fi
cd "$cd"
}
loader() {
if [ -z "$2" ]; then
target="$1"
else
target="$2"
if [ "${SILENT:-0}" != "1" ]; then
set +x
echo
echo "##############################"
echo "$1"
echo "##############################"
set -x
fi
fi
# shellcheck disable=1090,2039
. "$target"
}