From 5dd16e14dd41f1565687142ba7cefa7c4cf64658 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 12 Nov 2013 13:39:41 +0100 Subject: wip --- lib/common | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'lib/common') diff --git a/lib/common b/lib/common index 2214480..f44dde8 100755 --- a/lib/common +++ b/lib/common @@ -9,7 +9,17 @@ then exit 1 fi -PATH=$APPSH_HOME:$PATH +##################################################################### +# Common init + +PATH=$APPSH_HOME:$APPSTORE_HOME:$PATH + +# Save for later +usage_app=${0##*/} +echo_debug=${echo_debug-no} + +##################################################################### +# Utilities show_help() { message=${1-} @@ -66,13 +76,28 @@ grep_path() { assert_valid_app_name() { local app="$1"; shift - local re="^[a-zA-Z][a-zA-Z0-9]*$" + local re="^[a-zA-Z][-_a-zA-Z0-9]*$" if [[ ! $app =~ $re ]] then fatal "Invalid app name: \"$app\"" fi } -# Save for later -usage_app=${0##*/} -echo_debug=${echo_debug-no} +##################################################################### +# + +make_absolute() { + local name=$1; shift + local value=${!name} + + if [[ $value = "." ]] + then + eval ${name}="$(pwd)" + elif [[ -e ${value} ]] + then + bn=$(basename ${value}) + path=$(cd ${value}/.. && pwd) + + eval ${name}=${path}/${bn} + fi +} -- cgit v1.2.3