Ensure that files marked executable are #! scripts

master
David Allsopp 2019-03-07 11:58:44 +00:00
parent 3f91e8750b
commit ed2ec2537f
1 changed files with 28 additions and 0 deletions

View File

@ -130,6 +130,25 @@ usage () {
exit 2
}
check_script () {
if [ "$($OCAML_CT_CAT "$OCAML_CT_PREFIX$1" \
| sed -ne '1s/^#!.*/#!/p')" != '#!' ] ; then
# These files are listed manually, rather than via gitattributes,
# because the list should never expand, and it should not be trivial to
# expand (the unix-execvpe test is an ultra-special-case!)
f=${1#./}
if [ "$f" != "boot/ocamlc" ] && [ "$f" != "boot/ocamllex" ] && \
[ "$f" != "testsuite/tests/lib-unix/unix-execvpe/subdir/script2" ] ; then
echo "$1 shouldn't be executable; either:"
echo " - Add a #! line"
echo " - Run chmod -x $1 (on Unix)"
echo " - Run git update-index --chmod=-x $1 (on Windows)"
echo "You may wish to check your core.fileMode setting"
EXIT_CODE=1
fi
fi
}
userrules=''
while : ; do
@ -180,6 +199,15 @@ EXIT_CODE=0
*$f*) is_cmd_line=true;;
*) is_cmd_line=false;;
esac
if [ -z "$OCAML_CT_PREFIX" ] ; then
if [ -x "$f" ] ; then
check_script "$f"
fi
else
if git ls-files -s "$f" | grep -q "^100755" ; then
check_script "$f"
fi
fi
if $path_in_index || $is_cmd_line; then :; else continue; fi
attr_rules=''
if $path_in_index; then