diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2009-08-11 01:14:29 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-26 00:30:13 -0600 |
commit | 24e77f63ae243c33e1d38792080eaec1db43f8f7 (patch) | |
tree | 75af0795dc89bb383a814747f07e72a2a744781b /rvs.sh | |
parent | 530c6ff02be9ce6604e16ac33ec24569a39f6b0c (diff) |
I don't think this will run, but I think the next step is to turn `rvs.sh' into
`rvs.c', so I'm going to go ahead and commit this.
Diffstat (limited to 'rvs.sh')
-rw-r--r-- | rvs.sh | 75 |
1 files changed, 59 insertions, 16 deletions
@@ -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 |