Skip to content

Commit 7a8ade7

Browse files
committed
dist/tools: fix shellcheck warnings in dlcache script
1 parent f3a5da8 commit 7a8ade7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

dist/tools/dlcache/dlcache.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ if [ "$(uname)" = Darwin ]; then
1313
local lockfile="$1"
1414
shift
1515

16-
while ! shlock -p $$ -f $lockfile; do
16+
while ! shlock -p "$$" -f "$lockfile"; do
1717
sleep 0.2
1818
done
1919

20-
$*
20+
"$@"
2121

22-
rm $lockfile
22+
rm "$lockfile"
2323
}
2424
else
2525
_locked() {
@@ -28,7 +28,7 @@ else
2828

2929
(
3030
flock -w 600 9 || exit 1
31-
$*
31+
"$@"
3232
) 9>"$lockfile"
3333
}
3434
fi
@@ -42,17 +42,17 @@ fi
4242
calcmd5() {
4343
local file="$1"
4444
local md5="$2"
45-
46-
local file_md5=$(${MD5} "$file" | cut -d\ -f1)
45+
local file_md5
46+
file_md5=$(${MD5} "$file" | cut -d\ -f1)
4747

4848
test "$md5" = "$file_md5"
4949
}
5050

5151
downloader() {
5252
if [ -n "$(command -v wget)" ]; then
53-
wget -nv "$1" -O $2
53+
wget -nv "$1" -O "$2"
5454
elif [ -n "$(command -v curl)" ]; then
55-
curl -L $1 -o $2
55+
curl -L "$1" -o "$2"
5656
else
5757
_echo "$0: neither wget nor curl available!"
5858
return 1
@@ -62,8 +62,9 @@ downloader() {
6262
download() {
6363
local url="$1"
6464
local _md5="$2"
65-
local basename_url=$(basename ${url})
66-
local target="${3:-${basename_url}}"
65+
local basename_url
66+
basename_url="$(basename "${url}")"
67+
local target="${3:-"${basename_url}"}"
6768

6869
[ -f "$target" ] && {
6970
# if our target file exists, check it's md5.
@@ -73,7 +74,8 @@ download() {
7374
}
7475
}
7576

76-
local filename="$(basename $url)"
77+
local filename
78+
filename="$(basename "$url")"
7779
[ -f "$DLCACHE_DIR/$filename" ] && {
7880
# if the file exists in cache, check it's md5 and possibly remove it.
7981
if calcmd5 "$DLCACHE_DIR/$filename" "$_md5"; then
@@ -105,4 +107,4 @@ download() {
105107
fi
106108
}
107109

108-
_locked "$DLCACHE_DIR/$(basename $1).locked" download "$@"
110+
_locked "$DLCACHE_DIR/$(basename "$1").locked" download "$@"

0 commit comments

Comments
 (0)