40 lines
559 B
Bash
Executable File
40 lines
559 B
Bash
Executable File
#!/bin/sh
|
|
|
|
usage () {
|
|
echo "Usage: ${0#*/} [DIRECTORY]..."
|
|
echo "Run all executable scripts in one or more directories"
|
|
|
|
exit $1
|
|
}
|
|
|
|
ERRORS=
|
|
|
|
if [ -z "$1" ]; then
|
|
usage 2
|
|
fi
|
|
|
|
for dir in "$@"; do
|
|
dir=${dir%/}
|
|
if [ ! -d "$dir" ]; then
|
|
echo "$dir: invalid directory"
|
|
|
|
usage 2
|
|
fi
|
|
|
|
for file in "$dir"/*; do
|
|
if [ -x "$file" ]; then
|
|
"$file"
|
|
|
|
if [ "$?" -gt 0 ]; then
|
|
ERRORS="$ERRORS $file"
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
|
|
if [ -n "$ERRORS" ]; then
|
|
echo "There were errors in the following scripts:$ERRORS"
|
|
|
|
exit 1
|
|
fi
|