From d84efc301a88dfce708290050f371b6241253be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20Aar=C3=B8e=20Dam?= Date: Thu, 19 Feb 2015 08:58:49 +0100 Subject: [PATCH] Print proper paths to user when using a absolute BOX path. --- tools/create_box.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/create_box.sh b/tools/create_box.sh index a16283c..cf401be 100755 --- a/tools/create_box.sh +++ b/tools/create_box.sh @@ -25,6 +25,12 @@ rebase(){ [[ "$?" -ne 0 ]] && error "Error during rebase" } +# Is absolute path +isabspath(){ + local path=${1} + [[ $path =~ ^/.* ]] +} + if [ -z "$1" ]; then usage exit 1 @@ -42,7 +48,7 @@ if [[ -z "$2" ]]; then BOX=$BOX_NAME.box else BOX="$2" - BOX_NAME=${BOX%.*} + BOX_NAME=$(basename ${BOX%.*}) fi [[ -f "$BOX" ]] && error "'$BOX': Already exists" @@ -94,8 +100,12 @@ EOF echo "==> Creating box, tarring and gzipping" tar cvzf $BOX --totals ./metadata.json ./Vagrantfile ./box.img -mv $BOX $CWD -echo "==> ${CWD}/${BOX} created" +# if box is in tmpdir move it to CWD before removing tmpdir +if ! isabspath $BOX; then + mv $BOX $CWD +fi + +echo "==> ${BOX} created" echo "==> You can now add the box:" echo "==> 'vagrant box add ${BOX} --name ${BOX_NAME}'"