diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-11-12 13:39:41 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-11-12 13:39:41 +0100 |
commit | 5dd16e14dd41f1565687142ba7cefa7c4cf64658 (patch) | |
tree | d571b793928cdf89feb6d040b359c3db2a00c766 /lib | |
parent | 0d92ff5fd34d79b54c30c38ac41bc600acf7b7c4 (diff) | |
download | appstore-5dd16e14dd41f1565687142ba7cefa7c4cf64658.tar.gz appstore-5dd16e14dd41f1565687142ba7cefa7c4cf64658.tar.bz2 appstore-5dd16e14dd41f1565687142ba7cefa7c4cf64658.tar.xz appstore-5dd16e14dd41f1565687142ba7cefa7c4cf64658.zip |
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/common | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -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 +} |