summaryrefslogtreecommitdiffstats
path: root/recurse_apply
diff options
context:
space:
mode:
Diffstat (limited to 'recurse_apply')
-rwxr-xr-xrecurse_apply33
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 $@