diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2009-07-26 18:00:01 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-26 00:30:12 -0600 |
commit | 13ac989be47ce85bd9776c9787c9dc17ddda92f8 (patch) | |
tree | 64960fa93cdd814c0a19a0b9d5d1bedbcccb708f /rvs.sh | |
parent | c283a7d4327d7d18620ac97e927d88d5667781a4 (diff) |
oops, I forgot to `bzr add' all the moved files :)
Diffstat (limited to 'rvs.sh')
-rw-r--r-- | rvs.sh | 107 |
1 files changed, 107 insertions, 0 deletions
@@ -0,0 +1,107 @@ +#!$$SHELL$$ +name='rvs' +ver='0.7.0' +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>. + +RVSDIR='$$libdir$$' +REPO=`$RVSDIR/repo` + +error() { + echo "$name: $1" >> /dev/stderr + exit 1 +} + +repo() { + repo='.rvs' + pwd=`pwd` + owd="$pwd" + + while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do + pwd=`pwd` + cd .. + done + + if [ -e "`pwd`/$repo" ]; then + echo "`pwd`/$repo" + else + echo "$name: no rvs repository found" >> /dev/stderr + exit 1 + fi + cd "$owd" +} + + +init() { + repo=`repo` + if [ -z "$repo" ]; then + repo='.rvs' + install -d "$repo" + fi + + if diff -q $RVSDIR/plugins $repo/plugins; then + install -T $RVSDIR/plugins $repo/plugins + while read plugin; do + if [ ! -e "$repo/$plugin" ]; then + install -d "$repo/$plugin" + if [ -e "$RVSDIR/$plugin/init" ]; then + $RVSDIR/$plugin/init + fi + fi + done < $repo/plugins + fi +} + +# START OPTION HANDLING # +com=$1; +# END OPTION HANDLING # +case "$com" in + '') error 'no command specified';; + 'repo') repo;; + 'init') init;; + *) + if [ -f "$RVSDIR/$com" ]; then + export RVSDIR + $RVSDIR/$@ + done='yes' + else + while read plugin; do + if [ -f "$RVSDIR/$plugin/$com" ]; then + export RVSDIR=$RVSDIR/$plugin + export REPO=$REPO/$plugin + $RVSDIR/$@ + done='yes' + break + fi + done < $REPO/plugins + fi + if [ "$done" != 'yes' ]; then + error "unrecognized command \`$com'" + fi + :;; +esac + +#args=`getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@"` +#if [ $? == 0 ]; then +# set -- $args +# while [ $# -gt 0 ]; do +# case "$1" in +# -V | --version) mode='version';; +# -h | -H | -\? | --help) mode='help';; +# +# -v | --verbose) volume='-v';; +# -q | --quiet) volume='-q';; +# +# --) shift; break;; +# esac +# shift; +# done +#else +# error +#fi + |