From 63d088144fb8a956c2f7143e2a8ba1cd5806e780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 14 Jun 2011 09:11:45 +0200 Subject: add recurse_apply --- recurse_apply | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 recurse_apply 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 $@ -- cgit v1.1-2-g2b99