Skip to content
This repository was archived by the owner on Jul 2, 2020. It is now read-only.

Commit c457d3f

Browse files
committed
pandocDownload2zip.sh: quoting all strings
in case there are spaces
1 parent 2778b41 commit c457d3f

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

pandocDownload2zip.sh

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@
88
## macOS: `brew install msitools`
99

1010
# debug msg
11-
if [[ $DEBUG == "true" ]]; then
12-
echo $VERSION
11+
if [[ "$DEBUG" == "true" ]]; then
12+
echo "$VERSION"
1313
fi
1414

1515
# url to pandoc version
1616
url="https://github.com/jgm/pandoc/releases/tag/$VERSION"
1717
# debug msg
18-
if [[ $DEBUG == "true" ]]; then
19-
echo $url
18+
if [[ "$DEBUG" == "true" ]]; then
19+
echo "$url"
2020
fi
2121

2222
# get url to pandoc binaries
23-
debUrlPartial=$(curl -L $url | grep -o '/jgm/pandoc/releases/download/.*\.deb')
24-
pkgUrlPartial=$(curl -L $url | grep -o '/jgm/pandoc/releases/download/.*\.pkg')
25-
msiUrlPartial=$(curl -L $url | grep -o '/jgm/pandoc/releases/download/.*\.msi')
26-
zipUrlPartial=$(curl -L $url | grep -o '/jgm/pandoc/archive/.*\.zip')
27-
tarUrlPartial=$(curl -L $url | grep -o '/jgm/pandoc/archive/.*\.tar\.gz')
23+
debUrlPartial=$(curl -L "$url" | grep -o '/jgm/pandoc/releases/download/.*\.deb')
24+
pkgUrlPartial=$(curl -L "$url" | grep -o '/jgm/pandoc/releases/download/.*\.pkg')
25+
msiUrlPartial=$(curl -L "$url" | grep -o '/jgm/pandoc/releases/download/.*\.msi')
26+
zipUrlPartial=$(curl -L "$url" | grep -o '/jgm/pandoc/archive/.*\.zip')
27+
tarUrlPartial=$(curl -L "$url" | grep -o '/jgm/pandoc/archive/.*\.tar\.gz')
2828
# debug msg
29-
if [[ $DEBUG == "true" ]]; then
30-
echo $debUrlPartial
31-
echo $pkgUrlPartial
32-
echo $msiUrlPartial
33-
echo $zipUrlPartial
34-
echo $tarUrlPartial
29+
if [[ "$DEBUG" == "true" ]]; then
30+
echo "$debUrlPartial"
31+
echo "$pkgUrlPartial"
32+
echo "$msiUrlPartial"
33+
echo "$zipUrlPartial"
34+
echo "$tarUrlPartial"
3535
fi
3636

3737
# prepare dist folder
@@ -42,78 +42,78 @@ mkdir -p dist
4242
if [[ ! -z "$debUrlPartial" ]]; then
4343
# variables
4444
debUrl="https://github.com$debUrlPartial"
45-
DEB=${debUrl##*/}
46-
debWoExt=${DEB%.*}
47-
debZip=$debWoExt.zip
45+
DEB="${debUrl##*/}"
46+
debWoExt="${DEB%.*}"
47+
debZip="$debWoExt.zip"
4848
# download
49-
wget $debUrl
49+
wget "$debUrl"
5050
# unpack
51-
ar x $DEB data.tar.gz && mv data.tar.gz $debWoExt.tar.gz
52-
tar -zxvf $debWoExt.tar.gz && mv usr $debWoExt
51+
ar x "$DEB" data.tar.gz && mv data.tar.gz "$debWoExt.tar.gz"
52+
tar -zxvf "$debWoExt.tar.gz" && mv usr "$debWoExt"
5353
# zip
54-
zip -r $debZip $debWoExt
54+
zip -r "$debZip" "$debWoExt"
5555
# to dist/
56-
mv $DEB dist/
57-
mv $debZip dist/
58-
mv $debWoExt.tar.gz dist/
56+
mv "$DEB" dist/
57+
mv "$debZip" dist/
58+
mv "$debWoExt.tar.gz" dist/
5959
fi
6060
## macOS
6161
if [[ ! -z "$pkgUrlPartial" ]]; then
6262
# variables
6363
pkgUrl="https://github.com$pkgUrlPartial"
64-
PKG=${pkgUrl##*/}
65-
pkgWoExt=${PKG%.*}
66-
pkgZip=$pkgWoExt.zip
64+
PKG="${pkgUrl##*/}"
65+
pkgWoExt="${PKG%.*}"
66+
pkgZip="$pkgWoExt.zip"
6767
# download
68-
wget $pkgUrl
68+
wget "$pkgUrl"
6969
# unpack
7070
if [[ `uname` == "Darwin" ]]; then
71-
mkdir $pkgWoExt-pkg && xar -xf $PKG -C $pkgWoExt-pkg
71+
mkdir "$pkgWoExt-pkg" && xar -xf "$PKG" -C "$pkgWoExt-pkg"
7272
else
73-
7z x $PKG -o"$pkgWoExt-pkg"
73+
7z x "$PKG" -o"$pkgWoExt-pkg"
7474
fi
75-
cat $pkgWoExt-pkg/pandoc.pkg/Payload | gunzip -dc |cpio -i && mv usr $pkgWoExt
75+
cat "$pkgWoExt-pkg/pandoc.pkg/Payload" | gunzip -dc |cpio -i && mv usr "$pkgWoExt"
7676
# zip
77-
zip -r $pkgZip $pkgWoExt
77+
zip -r "$pkgZip" "$pkgWoExt"
7878
# to dist/
79-
mv $PKG dist/
80-
mv $pkgZip dist/
79+
mv "$PKG" dist/
80+
mv "$pkgZip" dist/
8181
fi
8282
## Windows
8383
if [[ ! -z "$msiUrlPartial" ]]; then
8484
# variables
8585
msiUrl="https://github.com$msiUrlPartial"
86-
MSI=${msiUrl##*/}
87-
msiWoExt=${MSI%.*}
88-
msiZip=$msiWoExt.zip
86+
MSI="${msiUrl##*/}"
87+
msiWoExt="${MSI%.*}"
88+
msiZip="$msiWoExt.zip"
8989
# download
90-
wget $msiUrl
90+
wget "$msiUrl"
9191
# unpack
92-
msiextract $MSI && mv "Program Files/Pandoc" $msiWoExt && rm -rf "Program Files"
92+
msiextract "$MSI" && mv "Program Files/Pandoc" "$msiWoExt" && rm -rf "Program Files"
9393
# zip
94-
zip -r $msiZip $msiWoExt
94+
zip -r "$msiZip" "$msiWoExt"
9595
# to dist/
96-
mv $MSI dist/
97-
mv $msiZip dist/
96+
mv "$MSI" dist/
97+
mv "$msiZip" dist/
9898
fi
9999
## Source Code
100100
### .zip
101101
if [[ ! -z "$zipUrlPartial" ]]; then
102102
# variables
103103
zipUrl="https://github.com$zipUrlPartial"
104-
ZIP=${zipUrl##*/}
104+
ZIP="${zipUrl##*/}"
105105
# download
106-
wget $zipUrl
106+
wget "$zipUrl"
107107
# rename & to dist/
108-
mv $ZIP dist/pandoc-source-code-$ZIP
108+
mv "$ZIP" "dist/pandoc-source-code-$ZIP"
109109
fi
110110
### .tar.gz
111111
if [[ ! -z "$tarUrlPartial" ]]; then
112112
# variables
113113
tarUrl="https://github.com$tarUrlPartial"
114-
TAR=${tarUrl##*/}
114+
TAR="${tarUrl##*/}"
115115
# download
116-
wget $tarUrl
116+
wget "$tarUrl"
117117
# rename & to dist/
118-
mv $TAR dist/pandoc-source-code-$TAR
118+
mv "$TAR" "dist/pandoc-source-code-$TAR"
119119
fi

0 commit comments

Comments
 (0)