Skip to contentSkip to conversation

check-tree.sh: check and flag /bin/sh usage

PATCH In review Florian Westphal 2 participants 2 messages Oct 24, 2023 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 check-tree.sh: check and flag /bin/sh usage

Almost all shell tests use /bin/bash already.

In some cases we've had shell tests use /bin/sh, but still having a bashism. This causes failures on systems where sh is dash or another, strict bourne shell.

Flag those via check-tree.sh.

---
 tests/shell/testcases/sets/elem_opts_compat_0 | 2 +-
 tools/check-tree.sh                           | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
tests/shell/testcases/sets/elem_opts_compat_0 +1 -1
index e0129536fcb7..3467cc07e646 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # ordering of element options and expressions has changed, make sure parser
 # accepts both ways
tools/check-tree.sh +1 -0
index c3aaa08d05ce..e3ddf8bdea58 100755
@@ -68,6 +68,7 @@ if [ "${#SHELL_TESTS[@]}" -eq 0 ] ; then
 fi
 for t in "${SHELL_TESTS[@]}" ; do
 	check_shell_dumps "$t"
+	head -n 1 "$t" |grep -q  '^#!/bin/sh' && echo "$t uses sh instead of bash" && EXIT_CODE=1
 done
 
 ##############################################################################
Signature · 1 line
2.41.0
#1 lore raw
Quoted 19 lines · Florian Westphal

Almost all shell tests use /bin/bash already.

In some cases we've had shell tests use /bin/sh, but still having a bashism. This causes failures on systems where sh is dash or another, strict bourne shell.

Flag those via check-tree.sh.

---
 tests/shell/testcases/sets/elem_opts_compat_0 | 2 +-
 tools/check-tree.sh                           | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
tests/shell/testcases/sets/elem_opts_compat_0 +0 -0
index e0129536fcb7..3467cc07e646 100755

tests/shell/testcases/sets/elem_opts_compat_0 line 4

Quoted 5 lines
tests/shell/testcases/sets/elem_opts_compat_0 +1 -1
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # ordering of element options and expressions has changed, make sure parser
 # accepts both ways

Amend before applying, I was too fast to push out the fix for elem_opts_compat_0.

Thanks.

Quoted 15 lines
tools/check-tree.sh +1 -0
index c3aaa08d05ce..e3ddf8bdea58 100755
@@ -68,6 +68,7 @@ if [ "${#SHELL_TESTS[@]}" -eq 0 ] ; then
 fi
 for t in "${SHELL_TESTS[@]}" ; do
 	check_shell_dumps "$t"
+	head -n 1 "$t" |grep -q  '^#!/bin/sh' && echo "$t uses sh instead of bash" && EXIT_CODE=1
 done
 
 ##############################################################################
Signature · 1 line
2.41.0