diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-10-22 20:40:50 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-10-22 20:40:50 +0200 |
commit | 34e60841a44ee688792e87863aa67db469d39fa8 (patch) | |
tree | d4ec57728121d87b029d8b729c98494356015061 /appstore | |
parent | 4452df33f080c314f9b4c6a6504f254edc500282 (diff) | |
download | appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.gz appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.bz2 appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.xz appstore-34e60841a44ee688792e87863aa67db469d39fa8.zip |
wip
Diffstat (limited to 'appstore')
-rwxr-xr-x | appstore | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/appstore b/appstore new file mode 100755 index 0000000..eee4774 --- /dev/null +++ b/appstore @@ -0,0 +1,58 @@ +#!/bin/bash -e + +PRG="$0" +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi +done + +APPSTORE_HOME=`dirname "$PRG"` +APPSTORE_HOME=`cd "$APPSTORE_HOME" && pwd` + +. $APPSTORE_HOME/lib/common + +usage_text() { + echo "usage: $usage_app <command>" + echo "" + echo "Available porcelain commands:" + grep_path "/appstore-.*$" "$APPSTORE_HOME/bin" | \ + sed "s,^.*/appstore-, ," | \ + sort -n + echo "" + echo "Available plumbing commands:" + grep_path "/appstore-.*$" "$APPSTORE_HOME/libexec" | \ + sed "s,^.*/appstore-, ," | \ + sort -n +} + +if [ $# -eq 0 ] +then + usage +fi + +command=$1; shift + +bin=`grep_path "/appstore-$command$" "$APPSTORE_HOME/bin"` + +if [ ! -x "$bin" ] +then + bin=`grep_path "/appstore-$command$" "$APPSTORE_HOME/libexec"` + if [ ! -x "$bin" ] + then + echo "Unknown command: $command" 2>&1 + exit 1 + fi +fi + +PATH=$APPSTORE_HOME/bin:$PATH + +# TODO: this is probably a good place to clean up the environment +exec env \ + "APPSTORE_HOME=$APPSTORE_HOME" \ + "echo_debug=$echo_debug" \ + "$bin" "$@" |