@@ -11,6 +11,10 @@ msg() {
11
11
echo >&2 " $me " : " $* "
12
12
}
13
13
14
+ debug () {
15
+ [ -n " $DEBUG " ] && msg debug: " $* "
16
+ }
17
+
14
18
log_stdin () {
15
19
while read -r i; do
16
20
msg " $i "
@@ -59,6 +63,7 @@ ARCH=$arch
59
63
PROFILED=$profiled
60
64
CACHE=$cache
61
65
GOPATH=$GOPATH
66
+ DEBUG=$DEBUG
62
67
EOF
63
68
}
64
69
@@ -84,11 +89,14 @@ die() {
84
89
85
90
solve () {
86
91
local path=$1
92
+ local p=
87
93
if echo " $path " | egrep -q ^/; then
88
- echo " $path "
94
+ p=" $path "
95
+ debug solve: " $p " : ` file " $p " `
89
96
else
90
- echo " $save_dir /$path "
97
+ p= " $save_dir /$path "
91
98
fi
99
+ echo " $p "
92
100
}
93
101
94
102
abs_filepath=$( solve " $filepath " )
@@ -132,10 +140,15 @@ remove_old_link() {
132
140
[ -r " $abs_goroot " ] && die could not remove existing golang directory: " $abs_goroot "
133
141
}
134
142
143
+ rm_dir () {
144
+ local dir=$1
145
+ rm -r " $dir "
146
+ }
147
+
135
148
untar () {
136
149
if [ -d " $abs_new_install " ]; then
137
- msg untar: rm -r " $abs_new_install "
138
- rm -r " $abs_new_install " || die untar: could not remove: " $abs_new_install "
150
+ msg untar: rm_dir " $abs_new_install "
151
+ rm_dir " $abs_new_install " || die untar: could not remove: " $abs_new_install "
139
152
fi
140
153
[ -d " $PWD " ] || die untar: not a directory: " $PWD "
141
154
[ -w " $PWD " ] || die untar: unable to write: " $PWD "
@@ -231,7 +244,7 @@ remove_golang() {
231
244
msg remove: removing symlink: " $abs_goroot "
232
245
rm " $abs_goroot "
233
246
msg remove: removing dir: " $old_install "
234
- rm -r " $old_install "
247
+ rm_dir " $old_install "
235
248
else
236
249
msg remove: not found symlink for old install
237
250
fi
@@ -244,7 +257,7 @@ remove_old_install() {
244
257
if [ " $abs_old_install " != " $abs_new_install " ]; then
245
258
# remove old install only if it actually changed
246
259
msg removing old install: " $abs_old_install "
247
- rm -r " $abs_old_install "
260
+ rm_dir " $abs_old_install "
248
261
fi
249
262
fi
250
263
}
0 commit comments