]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - run-parts
- 0.4.3.7
[projects/rc-scripts.git] / run-parts
index cb24757e7bae84c463b6de195156b986be841be2..8b473a599fafb6ea0dac8725efa484797bcb759a 100755 (executable)
--- a/run-parts
+++ b/run-parts
@@ -2,7 +2,7 @@
 
 # run-parts - concept taken from Debian
 #
-# modified for PLD by Pawel Wilk <siefca@pld.org.pl>
+# modified for PLD Linux by Pawel Wilk <siefca@pld-linux.org>
 #
 # NOTE:
 #      1.) run-parts is now able to get arguments!
 # keep going when something fails
 set +e
 
+if [ "$1" = "--test" ]; then
+       test=yes
+       shift
+fi
+
+if [ "$1" = "--" ]; then
+       shift
+fi
+
 # std checks
 if [ $# -lt 1 ]; then
-       echo "Usage: run-parts <dir> <args...>"
+       echo "Usage: run-parts [-u] [--test] <dir> <args...>"
        exit 1
 fi
 
 if [ ! -d $1 ]; then
        echo "Is not a directory: $1"
-       echo "Usage: run-parts <dir> <args...>"
+       echo "Usage: run-parts [-u] [--test] <dir> <args...>"
        exit 1
 fi
 
@@ -31,9 +40,9 @@ fi
 RUNPARTS_DIR=$1
 
 # assign absolute dir name
-olddir=`pwd`
+olddir=$(pwd)
 cd $RUNPARTS_DIR
-RUNPARTS_ADIR=`pwd`
+RUNPARTS_ADIR=$(pwd)
 cd $olddir
 unset olddir
 
@@ -43,11 +52,28 @@ export RUNPARTS_ADIR RUNPARTS_DIR
 # shift args
 shift
 
-# exec progs if any
-for i in $RUNPARTS_DIR/* ; do
-       [ -d $i ] && continue
-       if [ -x $i ]; then
-               $i $*
+# Ignore *~ and *, scripts
+for i in $RUNPARTS_DIR/*[!~,] ; do
+       [ -d "$i" ] && continue
+       # Don't run *.{rpmsave,rpmorig,rpmnew,swp} scripts
+       [ "${i%.rpmsave}" != "${i}" ] && continue
+       [ "${i%.rpmorig}" != "${i}" ] && continue
+       [ "${i%.rpmnew}" != "${i}" ] && continue
+       [ "${i%.swp}" != "${i}" ] && continue
+       [ "${i%,v}" != "${i}" ] && continue
+
+       if [ -x "$i" ]; then
+               runprog="$i $@"
+               if [ "$test" = yes ]; then
+                       echo "$runprog"
+                       continue
+               fi
+               $runprog 2>&1 | awk -v "progname=$i" \
+                       'progname {
+                               print progname ":\n"
+                               progname="";
+                               }
+                       { print; }'
        fi
 done
 
This page took 0.0447 seconds and 4 git commands to generate.