aboutsummaryrefslogtreecommitdiffstats
path: root/tools/check-shebang.sh
diff options
context:
space:
mode:
authorMark Johnston <markjdb@gmail.com>2020-11-02 14:39:30 -0500
committerGitHub <noreply@github.com>2020-11-02 11:39:30 -0800
commit7f344fa6473fd40c7a5c006e5cb6a3017b4fc193 (patch)
tree2fa7f2d9cf783c7a09cc6c1b98aec37e16f8e2fb /tools/check-shebang.sh
parentf73622566ee98c1b4d780bf4ad28fbdbde4fdcaa (diff)
tools: add script to check shebang lines (#2234)
* pkg/vcs: remove obsolete test script Per Dmitry, this should have been removed as part of 8f58e4b ("pkg/bisect: switch to kconfig.Minimize"). * all: convert shebang lines to use /usr/bin/env * Makefile: fix non-portable use of find(1)
Diffstat (limited to 'tools/check-shebang.sh')
-rwxr-xr-xtools/check-shebang.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/check-shebang.sh b/tools/check-shebang.sh
new file mode 100755
index 000000000..a7c1e67dd
--- /dev/null
+++ b/tools/check-shebang.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+# Copyright 2020 syzkaller project authors. All rights reserved.
+# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+FAILED=""
+FILES=0
+for F in $(find . -perm -u=x -type f | egrep -v "/vendor/|/gen/|/.git"); do
+ ((FILES+=1))
+ if head -n 1 "$F" | egrep -q '^#!/' && head -n 1 "$F" | egrep -v -q -e '^#!/bin/sh$' -e '^#!/usr/bin/env '; then
+ echo "$F: Non-portable shebang line. Please use /usr/bin/env to locate the interpreter."
+ FAILED=1
+ fi
+done
+[ -n "$FAILED" ] && exit 1
+echo "$FILES files checked for non-portable shebang lines"