# keep going when something fails
set +e
-if [ "$1" = "-u" ]; then
- workasuser=yes
+if [ "$1" = "--test" ]; then
+ test=yes
+ shift
+fi
+
+if [ "$1" = "--" ]; then
shift
fi
# std checks
if [ $# -lt 1 ]; then
- echo "Usage: run-parts [-u] <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 [-u] <dir> <args...>"
+ echo "Usage: run-parts [-u] [--test] <dir> <args...>"
exit 1
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
if [ -x "$i" ]; then
runprog="$i $@"
- if [ "$workasuser" = "yes" ]; then
- runuser="$(/bin/ls -l "$i" | awk ' { print $3 } ' 2> /dev/null)"
- [ -z "$runuser" ] && echo "Warning: Can't find owner for [$i] file. Not running." && continue
- runprog="/bin/su $runuser -s /bin/sh -c $runprog"
+ if [ "$test" = yes ]; then
+ echo "$runprog"
+ continue
fi
$runprog 2>&1 | awk -v "progname=$i" \
'progname {
done
exit 0
-
-# This must be last line !
-# vi:syntax=sh