blob: fa94befdcbe82f59b58d1bea937d14ad8daa0af6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/env bash
#
# Usage:
# maint/forbid-absolute-shebangs
#
# Requires that scripts all start with `#! /usr/bin/env`,
# not a path to a specific interpreter.
set -euo pipefail
# this include stanza is automatically maintained by update-shell-includes
common_dir=$(realpath "$0")
common_dir=$(dirname "$common_dir")
# shellcheck source=maint/common/bash-utils.sh
. "$common_dir"/bash-utils.sh
reject_all_arguments
set +e
git grep -rnI '^#\!/' :/ | grep -v '#\!/usr/bin/env'
st="${PIPESTATUS[*]}"
set -e
case "$st" in
"0 0")
echo "Absolute shebangs found, replace them with \"#!/usr/bin/env\""
exit 1
;;
"0 1")
echo "Everything seems ok"
exit 0
;;
*)
echo "ERROR - status $st"
exit 16
;;
esac
|