From 97036aeae73cc2a63219c7b792ab5f18c7d98cd1 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 1 Feb 2013 09:28:18 +0100 Subject: libexec/app-resolver-maven: Better argument checking. lib/common: Starting a way to have a common usage/help semantics. --- bin/app-init | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'bin/app-init') diff --git a/bin/app-init b/bin/app-init index 018b210..ba97ebd 100755 --- a/bin/app-init +++ b/bin/app-init @@ -8,14 +8,8 @@ APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) . $APPSH_HOME/lib/common # HEADER END -usage() { - echo "usage: $0 -d dir " - exit 1 -} - -fatal() { - echo "$0: $@" - exit 1 +usage_inner() { + echo "usage: $usage_app -d dir " } while getopts "d:" opt @@ -46,8 +40,6 @@ then fatal "Already initialized: $dir" 2>&1 fi -# TODO: install a trap handler and rm -rf "$dir" - resolver=`grep_path "/app-resolver-$resolver_name$" "$PATH" | head -n 1` if [ -z "$resolver" ] @@ -57,6 +49,11 @@ then fi mkdir -p -- "$dir" "$dir/.app" + +ok=no +clean_dir=`cd "$dir">/dev/null; pwd` +trap '[[ $ok == yes ]] || rm -rf "$clean_dir"' EXIT + cd "$dir" app-conf set app.resolver "$resolver_name" @@ -77,3 +74,5 @@ echo "Resolved version to $version" "$resolver" download-version -v "$version" -f .app/latest.zip app-install-file -v "$version" -f .app/latest.zip + +ok=yes -- cgit v1.2.3