diff options
| author | David Allsopp <david.allsopp@metastack.com> | 2019-03-07 11:58:44 +0000 |
|---|---|---|
| committer | David Allsopp <david.allsopp@metastack.com> | 2019-03-27 10:32:40 +0000 |
| commit | ed2ec2537f0851a4e57dddca480394aba2384a46 (patch) | |
| tree | ad15d9b0f73d3ec7f507875bcd20f461810f71d2 /tools | |
| parent | 3f91e8750bbb9a9dc9fb979ce586d7c585e71b86 (diff) | |
| download | ocaml-ed2ec2537f0851a4e57dddca480394aba2384a46.tar.gz | |
Ensure that files marked executable are #! scripts
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/check-typo | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/check-typo b/tools/check-typo index 5c411dfaf9..6da3c3e6b7 100755 --- a/tools/check-typo +++ b/tools/check-typo @@ -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 |
