diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-06-14 09:11:45 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-06-14 09:11:45 +0200 |
commit | 63d088144fb8a956c2f7143e2a8ba1cd5806e780 (patch) | |
tree | bee9ca258ece14f3bbc29cc0351cd7657d030f2f | |
parent | c4810170979d2d2fb9cf1100c6345556c5ac01a8 (diff) | |
download | bin-63d088144fb8a956c2f7143e2a8ba1cd5806e780.zip bin-63d088144fb8a956c2f7143e2a8ba1cd5806e780.tar.gz |
add recurse_apply
-rwxr-xr-x | recurse_apply | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/recurse_apply b/recurse_apply new file mode 100755 index 0000000..3e7c4e6 --- /dev/null +++ b/recurse_apply @@ -0,0 +1,33 @@ +#! /bin/sh + +R=${R:-"0"} # recurse +X=${X:-"0"} # apply CMD on executable files +V=${V:-"0"} # verbose mode +CMD=${CMD:-"file"} +recurse_apply() { + #echo $@ $V $R $X $CMD + for I in $@; do + if test ! -r $I || test ! -w $I ; then + if test $V -eq 1; then echo "->passing $I (not rw)"; fi + else + if test -d $I && test $R -eq 1 ; then + recurse_apply ${I%/}/* + elif test -f $I ; then + if test -x $I; then + if test $X -eq 1; then + if test $V -eq 1; then echo " $CMD $I"; fi + $CMD $I || echo "**** error while executing $CMD $I" + else #if test $V -eq 1; then + echo "$I is executable, use -x to force."; + fi + else + if test $V -eq 1; then echo " $CMD $I"; fi + $CMD $I || echo "**** error while executing $CMD $I" + fi + elif test $V -eq 1; then + echo "->passing $I (not a directory or not file)" + fi + fi + done +} +recurse_apply $@ |