#!/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 " 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" "$@"