|
|
|
@ -21,7 +21,7 @@ srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
|
|
|
|
|
# NFS issues sometimes cause scripts to rewritten from vim without executable bit set, which then gets committed to git by accident
|
|
|
|
|
|
|
|
|
|
section "Find Non Executable Scripts"
|
|
|
|
|
section "Finding Non Executable Scripts"
|
|
|
|
|
|
|
|
|
|
script_extensions="
|
|
|
|
|
sh
|
|
|
|
@ -30,23 +30,23 @@ pl
|
|
|
|
|
rb
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
name_opt=""
|
|
|
|
|
ext_regex=""
|
|
|
|
|
for ext in $script_extensions; do
|
|
|
|
|
name_opt="$name_opt -o -name '*.$ext'"
|
|
|
|
|
ext_regex="$ext_regex|\.$ext"
|
|
|
|
|
done
|
|
|
|
|
name_opt="${name_opt# -o }"
|
|
|
|
|
ext_regex="(${ext_regex#|})$"
|
|
|
|
|
|
|
|
|
|
set +o pipefail
|
|
|
|
|
# -executable switch not available on Mac
|
|
|
|
|
if ! is_linux; then
|
|
|
|
|
echo "Non-Linux system detected, skipping as find perm behaviour is broken on Mac"
|
|
|
|
|
return 0 &>/dev/null || :
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
# trying to build up successive -name options doesn't work and ruins the logic of find, simplify to grep
|
|
|
|
|
non_executable_scripts="$(eval find "${1:-.}" -maxdepth 2 -type f -not -perm -u+x | egrep "$ext_regex" | grep -v '/\.' | tee /dev/stderr)"
|
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
|
|
non_executable_scripts="$(eval find "${1:-.}" -maxdepth 2 -not -perm -500 -type f $name_opt)"
|
|
|
|
|
|
|
|
|
|
if [ -n "$non_executable_scripts" ]; then
|
|
|
|
|
echo
|
|
|
|
|
echo 'Non-executable scripts detected!'
|
|
|
|
|
echo
|
|
|
|
|
if [ -z "$non_executable_scripts" ]; then
|
|
|
|
|
echo "OK: no non-executable scripts detected"
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
echo 'FAILED: non-executable scripts detected!'
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|