summaryrefslogtreecommitdiff
path: root/rvs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'rvs.sh')
-rw-r--r--rvs.sh45
1 files changed, 20 insertions, 25 deletions
diff --git a/rvs.sh b/rvs.sh
index df8560c..9c3b7ac 100644
--- a/rvs.sh
+++ b/rvs.sh
@@ -11,12 +11,12 @@ ver='0.7.0'
RVSDIR="@libexecdir@/$name"
-error() {
+_error() {
echo "$name: $1" >> /dev/stderr
exit 1
}
-repo() {
+_repo() {
repo=".$name"
pwd=`pwd`
owd="$pwd"
@@ -29,35 +29,31 @@ repo() {
if [ -e "`pwd`/$repo" ]; then
echo "`pwd`/$repo"
else
- error "no $name repository found" >> /dev/stderr
+ _error "no $name repository found" >> /dev/stderr
fi
cd "$owd"
}
-init() {
- repo=`repo 2> /dev/null`
+_init() {
+ repo=`_repo 2> /dev/null`
if [ -z "$repo" ]; then
repo=".$name"
install -d "$repo"
install -T $RVSDIR/plugins $repo/plugins
while read plugin; do
echo "initializing plugin \`$plugin'"
- echo 'foo0'
install -d "$repo/$plugin"
- echo 'foo1'
export REPO=.rvs/$plugin
- echo 'foo2'
if [ -e "$RVSDIR/$plugin/init" ]; then
"$RVSDIR/$plugin/init"
fi
- echo 'foo3'
done < $repo/plugins
else
- error "repository already exists at \`$repo'"
+ _error "repository already exists at \`$repo'"
fi
}
-install() {
+_install() {
id=$1
dir=${2-$id}
name=`echo $id | sed 's/-.*$//'`
@@ -71,7 +67,7 @@ install() {
cp -rp "$dir" "$RVSDIR/$id"
}
-uninstall() {
+_uninstall() {
id=$1
sed -i "/^$id$/ d" "$RVSDIR/plugins"
rm -rf "$RVSDIR/$id"
@@ -81,30 +77,29 @@ uninstall() {
com=$1;
# END OPTION HANDLING #
case "$com" in
- '') error 'no command specified';;
+ '') _error 'no command specified';;
# 'repo') repo; exit $?;;
- 'init') init; exit $?;;
- 'install') shift; install $@; exit $?;;
- 'uninstall') shift; uninstall $@; exit $?;;
- *)
- if [ -f "$RVSDIR/$com" ]; then
- export RVSDIR
- $RVSDIR/$@
- done='yes'
- else
+ 'init') _init; exit $?;;
+ 'install') shift; _install $@; exit $?;;
+ 'uninstall') shift; _uninstall $@; exit $?;;
+ *) repo=`_repo`
+ if exit $?; then
while read plugin; do
if [ -f "$RVSDIR/$plugin/$com" ]; then
done='yes'
export RVSDIR=$RVSDIR/$plugin
- export REPO=`repo`/$plugin
+ export REPO=$repo/$plugin
+ echo $RVSDIR/$@
$RVSDIR/$@
exit $?
break
fi
- done < $REPO/plugins
+ done < $repi/plugins
+ else
+ exit 1;
fi
if [ "$done" != 'yes' ]; then
- error "unrecognized command \`$com'"
+ _error "unrecognized command \`$com'"
fi
:;;
esac