summaryrefslogtreecommitdiff
path: root/rvs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'rvs.sh')
-rw-r--r--rvs.sh75
1 files changed, 59 insertions, 16 deletions
diff --git a/rvs.sh b/rvs.sh
index b9ff973..f54f553 100644
--- a/rvs.sh
+++ b/rvs.sh
@@ -85,33 +85,76 @@ _uninstall() {
rm -rf "$libexecdir/$id"
}
+_treebranch() {
+ branch="$1"
+ for com in "$branch"; do
+ var="r_$com"
+ if [ -z "\$$var" ]; then
+ exec r$var="`$libexecdir/$com $param`"
+ var="_$com"
+ _treebranch "\$$var"
+ else
+ _error "plugin dependancy loop detected"
+ fi
+ done
+}
+
+_runcom() {
+ com="$1"
+ tmp_mast="`tempfile`"
+ # bash optimized version
+ #grep -E "^$com(:.*)?$" "$libexecdir/*/plugin.conf" | sed \
+ # -e 's/\#.*//' \
+ # -e "s:^${libexecdir//':'/'\:'}/::" \
+ # -e 's@plugin.conf\:@@' > "$tmp_mast"
+ # POSIX version
+ grep -E "^$com(:.*)?$" $libexecdir/*/plugin.conf | sed \
+ -e 's/\#.*//' \
+ -e "s:^`echo "$libexecdir" |sed 's@:@\\:@g'`/::" \
+ -e 's@plugin.conf\:@@' > "$tmp_mast"
+
+ # start processing-------------------------------------------
+ if [ "`wc -c < "$tmp_mast"`" = '0' ]; then
+ _error "unrecognized command \`$com'"
+ else
+ # create tree
+ tmp_work="`tempfile`"
+ lev1="`sed \
+ -e "/\:/w '$tmp_work'" \
+ -e '/\:/d' "$tmp_mast"`"
+ while read line; do
+ com="`echo "$line" | sed 's/\:.*$/'`"
+ dep="_`echo "$line" | sed 's/.*\:$/'`"
+ # bash optimized version
+ # eval $dep=\"${!dep} $com\"
+ # POSIX version
+ eval $dep=\"\$$dep $com\"
+ done < "$tmp_work"
+ rm "$tmp_work"
+
+ # cycle through tree
+ _treebranch "$lev1"
+ fi
+ rm "$tmp_mast"
+}
+
# START OPTION HANDLING #
com=$1;
# END OPTION HANDLING #
case "$com" in
'') _error 'no command specified';;
- # 'repo') repo; exit $?;;
+ # 'repo') _repo; exit $?;;
'init') _init; exit $?;;
'install') shift; _install $@; exit $?;;
'uninstall') shift; _uninstall $@; exit $?;;
*) repo=`_repo`
if [ "$?" = '0' ]; then
- while read plugin; do
- if [ -f "$libexecdir/$plugin/$com" ]; then
- done='yes'
- export libexecdir=$libexecdir/$plugin
- export REPO=$repo/$plugin
- export RVS
- $libexecdir/$@
- exit $?
- break
- fi
- done < "$repo/plugins"
+ shift
+ param="$@"
+ _runcom
+ exit $?
else
- exit 1;
- fi
- if [ "$done" != 'yes' ]; then
- _error "unrecognized command \`$com'"
+ _error "cannot find an existing repository"
fi
:;;
esac