diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2010-04-01 09:58:02 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-26 00:30:19 -0600 |
commit | 82a796c7820f3c3da49d4bfa4b83d4e5d0a36c9e (patch) | |
tree | 235f864b5dcc1425c66fb5d98b0b0876f70d71f9 /wrapper/rvs.sh | |
parent | 88cec538b5d576ae1e7de73efac2af5c3c84d17b (diff) |
add commit bindings to the tag and comment plugins. this is totally untested
Diffstat (limited to 'wrapper/rvs.sh')
-rw-r--r-- | wrapper/rvs.sh | 71 |
1 files changed, 48 insertions, 23 deletions
diff --git a/wrapper/rvs.sh b/wrapper/rvs.sh index bac92e5..e2e94e6 100644 --- a/wrapper/rvs.sh +++ b/wrapper/rvs.sh @@ -19,7 +19,7 @@ ver='0.9' # If not, see <http://www.gnu.org/licenses>. export RVS="$0" #RVS="@RVS@" -export BINDIR="@BINDIR@" + BINDIR="@BINDIR@" baseTMPDIR="@TMPDIR@" export LIBDIR="@LIBDIR@" export ETCDIR="@ETCDIR@" @@ -31,44 +31,56 @@ export ETCDIR="@ETCDIR@" # General ############################################################ _error() { - echo "$RVS: $@" >> /dev/stderr - exit 1 + echo "$RVS: $1" >> /dev/stderr + exit ${2-1} } # Repository ######################################################### _repo() { - repo=".$name" - owd="`pwd`" # old working directory - - # [----can ascend-----] && [-haven't found repo-] - while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do - pwd=`pwd` - cd .. - done - - if [ -e "`pwd`/$repo" ]; then - # we found a repository - echo "`pwd`/$repo" - else - # we didn't find a repository - _error "no $name repository found" + if [ -z "$REPO" ]; then # we aren't getting a value from then env + repo=".$name" + owd="`pwd`" # old working directory + + # [----can ascend-----] && [-haven't found repo-] + while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do + pwd=`pwd` + cd .. + done + + if [ -e "`pwd`/$repo" ]; then + # we found a repository + echo "`pwd`/$repo" + else + # we didn't find a repository + _error "no $name repository found" + fi + cd "$owd" fi - cd "$owd" } # Modules ############################################################ _runcom() { + # exit states + # 0 - fine + # 1 - could not find command + # 2 - could not run command usage="usage: $RVS runcom COMMAND" command=${1?"$usage"}; shift if [ ! -e "$BINDIR/$command" ]; then - _error "cannot find command \`$command" + exit 1 else mkdir -p "$baseTMPDIR" export TMPDIR=`mktemp -d --tmpdir="$baseTMPDIR"` + if [ -z "RVS_LEVEL" ]; then + export RVS_LEVEL=0; + else + export RVS_LEVEL=`expr $RVS_LEVEL + 1` + fi + if [ -f "$BINDIR/$command" ]; then exec "$BINDIR/$command" $@ | tee "$TMPDIR/$command" elif [ -d "$BINDIR/$command" ]; then @@ -79,7 +91,7 @@ _runcom() { done cat "$TMPDIR/$command/$id" else - _error "cannot run \`$command'" + exit 2 fi rm -rf "$TMPDIR" fi @@ -98,13 +110,22 @@ _nextpriority() { ################################################################################ _init() { + # exit states: + # 0 - fine + # 1 - repo already exists + # 2 - error running init commands REPO=`_repo 2> /dev/null` if [ -z "$REPO" ]; then export REPO="`pwd`/.$name" install -d "$REPO" _runcom init + case "$?" in + 0) exit 0;; + 1) exit 0;; + 2) _error 'error running init scripts' 2;; + esac else - _error "repository already exists at \`$REPO'" + _error "repository already exists at \`$REPO'" 1 fi } @@ -158,7 +179,11 @@ case "$com" in if [ "$?" = '0' ]; then export REPO _runcom $@ - exit $? + case "$?" in + 0) exit 0;; + 1) _error "could not find command \`$1'" 1;; + 2) _error "could not run command \`$1'" 2;; + esac else exit 1 fi |