summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-11-14 17:08:30 +0100
committerFlorian Westphal <fw@strlen.de>2023-11-15 13:12:06 +0100
commit6834658132a65e53e19aa217b12f1d01d93238b4 (patch)
treea1bb8cac1fafd1206dc13ccf2c4bb4e9a43c391e /tools
parentf9a177eb32fd1dc6ae1d18f224b1cbc7f53c700f (diff)
tools: check more strictly for bash shebang in "check-tree.sh"
There is no problem in principle to allow any executable/shebang. However, it also not clear why we would want to use anything except bash. Unless we have a good use case, check and reject anything else. Also not that `./tests/shell/run-tests.sh -x` only works if the shebang is either exactly "#!/bin/bash" or "#!/bin/bash -e". While it probably could be made work with other shebangs, the simpler thing is to just use bash consistently. Just check that they are all bash scripts. If there ever is a use-case, we can always adjust this check. Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/check-tree.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/check-tree.sh b/tools/check-tree.sh
index b16d37c4..4be874fc 100755
--- a/tools/check-tree.sh
+++ b/tools/check-tree.sh
@@ -72,8 +72,13 @@ if [ "${#SHELL_TESTS[@]}" -eq 0 ] ; then
fi
for t in "${SHELL_TESTS[@]}" ; do
check_shell_dumps "$t"
- if head -n 1 "$t" |grep -q '^#!/bin/sh' ; then
- msg_err "$t uses #!/bin/sh instead of /bin/bash"
+ if ! ( head -n 1 "$t" | grep -q '^#!/bin/bash\( -e\)\?$' ) ; then
+ # Currently all tests only use bash as shebang. That also
+ # works with `./tests/shell/run-tests.sh -x`.
+ #
+ # We could allow other shebangs, but for now there is no need.
+ # Unless you have a good reason, create a bash script.
+ msg_err "$t should use either \"#!/bin/bash\" or \"#!/bin/bash -e\" as shebang"
fi
done