summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2014-11-22 07:03:53 (GMT)
committerAssaf Gordon <assafgordon@gmail.com>2014-11-22 07:03:53 (GMT)
commitd96dabbfacfc56696a4b07e286dbfe8ff2123a83 (patch)
tree2f966fe0d757a538629bd9b4c813f902e3ccf69f
parent7c7f24f6cfbb268bc19181b80ec390782191e08a (diff)
downloadbin_scripts-d96dabbfacfc56696a4b07e286dbfe8ff2123a83.zip
bin_scripts-d96dabbfacfc56696a4b07e286dbfe8ff2123a83.tar.gz
bin_scripts-d96dabbfacfc56696a4b07e286dbfe8ff2123a83.tar.bz2
scripts: 'make_balloon' - improve usage(), portabiltiy
-rwxr-xr-xscripts/make_balloon.in21
1 files changed, 11 insertions, 10 deletions
diff --git a/scripts/make_balloon.in b/scripts/make_balloon.in
index cdcfecf..dc09c8a 100755
--- a/scripts/make_balloon.in
+++ b/scripts/make_balloon.in
@@ -39,15 +39,15 @@ Note:
}
SIZE=$1
-test -z "$SIZE" && die "missing SIZE parameter. See --help for detauls"
-test "x$1" = "x-h" || test "x$1" = "--help" && usage
+test -z "$SIZE" && die "missing SIZE parameter. See --help for details"
+test "x$1" = "x-h" || test "x$1" = "x--help" && usage
-echo "$SIZE" | grep -qE "^[0-9]+(K|KB|M|MB|G|GB|)?$" \
+echo "$SIZE" | grep -qE '^[0-9]+(K|KB|M|MB|G|GB)?$' \
|| die "invalid size '$SIZE'. See --help for details"
## find any existing ballons, create the next one
LAST_BALLOON=$(ls balloon* 2>/dev/null \
- | sed -r 's/balloon_?//' | sort -n | tail -n 1)
+ | sed 's/balloon_//' | sort -n | tail -n 1)
if [ -z "$LAST_BALLOON" ]; then
BALLOON=1
else
@@ -68,12 +68,13 @@ else
BLOCK=$(stat -c %o .) || exit 1
##Poor man's human-size expander
- SIZE=${SIZE/GB/000000000}
- SIZE=${SIZE/G/000000000}
- SIZE=${SIZE/MB/000000}
- SIZE=${SIZE/M/000000}
- SIZE=${SIZE/K/000}
- SIZE=${SIZE/KB/000}
+ SIZE=$(echo "$SIZE" \
+ | sed -e 's/GB$/000000000/' \
+ -e 's/G$/000000000/' \
+ -e 's/MB$/000000/' \
+ -e 's/M$/000000/' \
+ -e 's/K$/000/' \
+ -e 's/KB$/000/')
let COUNT=$SIZE/$BLOCK