github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/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 | grep -E -v "/gen/|/.git"); do
     8  	((FILES+=1))
     9  	if head -n 1 "$F" | grep -E -q '^#!/' && head -n 1 "$F" | grep -E -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"