github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/tools/check-shebang.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright 2020 syzkaller project authors. All rights reserved.
     3  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     4  
     5  FAILED=""
     6  FILES=0
     7  for F in $(find . -perm -u=x -type f | egrep -v "/vendor/|/gen/|/.git"); do
     8  	((FILES+=1))
     9  	if head -n 1 "$F" | egrep -q '^#!/' && head -n 1 "$F" | egrep -v -q -e '^#!/bin/sh$' -e '^#!/usr/bin/env '; then
    10  		echo "$F: Non-portable shebang line. Please use /usr/bin/env to locate the interpreter."
    11  		FAILED=1
    12  	fi
    13  done
    14  [ -n "$FAILED" ] && exit 1
    15  echo "$FILES files checked for non-portable shebang lines"