Skip to content

Commit 72882f4

Browse files
author
udhos
committed
Option for debug.
1 parent 3525470 commit 72882f4

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ before_install:
1010

1111
script:
1212
- shellcheck -e SC2153 pre-commit sha256-update.sh update-golang.sh
13-
- sudo ./update-golang.sh
14-
- sudo ./update-golang.sh
13+
- sudo DEBUG=1 ./update-golang.sh
14+
- sudo DEBUG=1 ./update-golang.sh
1515
- ls -al /usr/local
16-
- sudo ./update-golang.sh remove
16+
- sudo DEBUG=1 ./update-golang.sh remove
1717
- ls -al /usr/local

update-golang.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ msg() {
1111
echo >&2 "$me": "$*"
1212
}
1313

14+
debug() {
15+
[ -n "$DEBUG" ] && msg debug: "$*"
16+
}
17+
1418
log_stdin() {
1519
while read -r i; do
1620
msg "$i"
@@ -59,6 +63,7 @@ ARCH=$arch
5963
PROFILED=$profiled
6064
CACHE=$cache
6165
GOPATH=$GOPATH
66+
DEBUG=$DEBUG
6267
EOF
6368
}
6469

@@ -84,11 +89,14 @@ die() {
8489

8590
solve() {
8691
local path=$1
92+
local p=
8793
if echo "$path" | egrep -q ^/; then
88-
echo "$path"
94+
p="$path"
95+
debug solve: "$p": `file "$p"`
8996
else
90-
echo "$save_dir/$path"
97+
p="$save_dir/$path"
9198
fi
99+
echo "$p"
92100
}
93101

94102
abs_filepath=$(solve "$filepath")
@@ -132,10 +140,15 @@ remove_old_link() {
132140
[ -r "$abs_goroot" ] && die could not remove existing golang directory: "$abs_goroot"
133141
}
134142

143+
rm_dir() {
144+
local dir=$1
145+
rm -r "$dir"
146+
}
147+
135148
untar() {
136149
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"
139152
fi
140153
[ -d "$PWD" ] || die untar: not a directory: "$PWD"
141154
[ -w "$PWD" ] || die untar: unable to write: "$PWD"
@@ -231,7 +244,7 @@ remove_golang() {
231244
msg remove: removing symlink: "$abs_goroot"
232245
rm "$abs_goroot"
233246
msg remove: removing dir: "$old_install"
234-
rm -r "$old_install"
247+
rm_dir "$old_install"
235248
else
236249
msg remove: not found symlink for old install
237250
fi
@@ -244,7 +257,7 @@ remove_old_install() {
244257
if [ "$abs_old_install" != "$abs_new_install" ]; then
245258
# remove old install only if it actually changed
246259
msg removing old install: "$abs_old_install"
247-
rm -r "$abs_old_install"
260+
rm_dir "$abs_old_install"
248261
fi
249262
fi
250263
}

update-golang.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d92994f82de766ce6f5fd4d9d0d5cb8862ef538969c786729c01c482d3ff40a6 update-golang.sh
1+
e19e63ac69f9ad78f25c4ff9164d54d8f3a31d64d9bde643ec0dbe176dfbe5a5 update-golang.sh

0 commit comments

Comments
 (0)