Skip to content

support downloading into a folder with a space #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ getPackage() {
targetFile="$(pwd)/$REPO$suffix"
fi

if [ -e $targetFile ]; then
rm $targetFile
if [ -e "$targetFile" ]; then
rm "$targetFile"
fi

url=https://github.com/$OWNER/$REPO/releases/download/$version/$REPO$suffix
echo "Downloading package $url as $targetFile"

curl -sSLf $url --output $targetFile
curl -sSLf $url --output "$targetFile"

if [ $? -ne 0 ]; then
echo "Download Failed!"
exit 1
else
extractFolder=$(echo $targetFile | sed "s/${REPO}${suffix}//g")
extractFolder=$(echo "$targetFile" | sed "s/${REPO}${suffix}//g")
echo "Download Complete, extracting $targetFile to $extractFolder ..."
tar -xzf $targetFile -C $extractFolder
tar -xzf "$targetFile" -C "$extractFolder"
fi

if [ $? -ne 0 ]; then
Expand All @@ -87,15 +87,15 @@ getPackage() {
else
# Remove the tar file
echo "OK"
rm $targetFile
rm "$targetFile"

# Get the parent dir of the 'bin' folder holding the binary
targetFile=$(echo $targetFile | sed "s+/${REPO}${suffix}++g")
targetFile=$(echo "$targetFile" | sed "s+/${REPO}${suffix}++g")
suffix=$(echo $suffix | sed 's/.tgz//g')

targetFile="${targetFile}/bin/${REPO}${suffix}"

chmod +x $targetFile
chmod +x "$targetFile"

# Calculate SHA
shaurl=$(echo $url | sed 's/.tgz/.sha256/g')
Expand Down Expand Up @@ -126,14 +126,14 @@ getPackage() {
echo
echo "Running with sufficient permissions to attempt to move $REPO to $BINLOCATION"

mv $targetFile $BINLOCATION/$REPO
mv "$targetFile" $BINLOCATION/$REPO

if [ "$?" = "0" ]; then
echo "New version of $REPO installed to $BINLOCATION"
fi

if [ -e $targetFile ]; then
rm $targetFile
if [ -e "$targetFile" ]; then
rm "$targetFile"
fi

${SUCCESS_CMD}
Expand Down