[DRE-commits] [vagrant-libvirt] 119/163: Support spaces in paths, by quoting all variables.
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Apr 24 13:57:13 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag 0.0.26
in repository vagrant-libvirt.
commit 88991f0c1cfcabc4d584b4c2ec77921101b16ab1
Author: Jakob Aarøe Dam <jakob.a.dam at gmail.com>
Date: Thu Feb 26 09:46:04 2015 +0100
Support spaces in paths, by quoting all variables.
---
tools/create_box.sh | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/tools/create_box.sh b/tools/create_box.sh
index cf401be..d691a03 100755
--- a/tools/create_box.sh
+++ b/tools/create_box.sh
@@ -15,20 +15,20 @@ usage() {
# Print the image's backing file
backing(){
local img=${1}
- qemu-img info $img | grep 'backing file:' | cut -d ':' -f2
+ qemu-img info "$img" | grep 'backing file:' | cut -d ':' -f2
}
# Rebase the image
rebase(){
local img=${1}
- qemu-img rebase -p -b "" $img
+ qemu-img rebase -p -b "" "$img"
[[ "$?" -ne 0 ]] && error "Error during rebase"
}
# Is absolute path
isabspath(){
local path=${1}
- [[ $path =~ ^/.* ]]
+ [[ "$path" =~ ^/.* ]]
}
if [ -z "$1" ]; then
@@ -36,44 +36,44 @@ if [ -z "$1" ]; then
exit 1
fi
-IMG=$(readlink -e $1)
-[[ "$?" -ne 0 ]] && error "'$2': No such image"
+IMG=$(readlink -e "$1")
+[[ "$?" -ne 0 ]] && error "'$1': No such image"
-IMG_DIR=$(dirname $IMG)
-IMG_BASENAME=$(basename $IMG)
+IMG_DIR=$(dirname "$IMG")
+IMG_BASENAME=$(basename "$IMG")
+BOX=${2:-}
# If no box name is supplied infer one from image name
-if [[ -z "$2" ]]; then
+if [[ -z "$BOX" ]]; then
BOX_NAME=${IMG_BASENAME%.*}
BOX=$BOX_NAME.box
else
- BOX="$2"
- BOX_NAME=$(basename ${BOX%.*})
+ BOX_NAME=$(basename "${BOX%.*}")
fi
[[ -f "$BOX" ]] && error "'$BOX': Already exists"
CWD=$(pwd)
-TMP_DIR=$CWD/_tmp_package
-TMP_IMG=$TMP_DIR/box.img
+TMP_DIR="$CWD/_tmp_package"
+TMP_IMG="$TMP_DIR/box.img"
-mkdir -p $TMP_DIR
+mkdir -p "$TMP_DIR"
# We move / copy (when the image has master) the image to the tempdir
# ensure that it's moved back / removed again
-if [[ -n $(backing $IMG) ]]; then
+if [[ -n $(backing "$IMG") ]]; then
echo "==> Image has backing image, copying image and rebasing ..."
trap "rm -rf $TMP_DIR" EXIT
- cp $IMG $TMP_IMG
- rebase $TMP_IMG
+ cp "$IMG" "$TMP_IMG"
+ rebase "$TMP_IMG"
else
- trap "mv $TMP_IMG $IMG; rm -rf $TMP_DIR" EXIT
- mv $IMG $TMP_IMG
+ trap 'mv "$TMP_IMG" "$IMG"; rm -rf "$TMP_DIR"' EXIT
+ mv "$IMG" "$TMP_IMG"
fi
-cd $TMP_DIR
+cd "$TMP_DIR"
-IMG_SIZE=$(qemu-img info $TMP_IMG | grep 'virtual size' | awk '{print $3;}' | tr -d 'G')
+IMG_SIZE=$(qemu-img info "$TMP_IMG" | grep 'virtual size' | awk '{print $3;}' | tr -d 'G')
cat > metadata.json <<EOF
{
@@ -99,11 +99,11 @@ EOF
echo "==> Creating box, tarring and gzipping"
-tar cvzf $BOX --totals ./metadata.json ./Vagrantfile ./box.img
+tar cvzf "$BOX" --totals ./metadata.json ./Vagrantfile ./box.img
# if box is in tmpdir move it to CWD before removing tmpdir
-if ! isabspath $BOX; then
- mv $BOX $CWD
+if ! isabspath "$BOX"; then
+ mv "$BOX" "$CWD"
fi
echo "==> ${BOX} created"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git
More information about the Pkg-ruby-extras-commits
mailing list