Skip to contentSkip to conversation

Squash to "selftests: mptcp: add evts_get_info helper"

PATCH New Matthieu Baerts 1 participant 1 message Oct 22, 2023

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts

author maintainer
#0 lore raw

PATCH 1/1 Squash to "selftests: mptcp: add evts_get_info helper"

Fixed info and style issues reported by ShellCheck:

In tools/testing/selftests/net/mptcp/mptcp_lib.sh line 213:
grep "${2}" | sed -n 's/.*\('${1}':\)\([0-9a-f:.]*\).*$/\2/p;q'
^--^ SC2086 (info): Double quote to prevent globbing and word splitting.

  Did you mean:
          grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'

In tools/testing/selftests/net/mptcp/mptcp_lib.sh line 218:

          cat "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
              ^----^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

The first one is just to be on the safe side and the second one is just a bit better but still, there were the only two issues reported by
ShellCheck: better to fix them to easily spot important issues.

---

Notes:
to be squashed in "selftests: mptcp: add evts_get_info helper"

 tools/testing/selftests/net/mptcp/mptcp_lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_lib.sh +2 -2
index def35395a254..56cbd57abbae 100644
@@ -210,10 +210,10 @@ mptcp_lib_result_print_all_tap() {
 
 # get the value of keyword $1 in the line marked by keyword $2
 mptcp_lib_get_info_value() {
-	grep "${2}" | sed -n 's/.*\('${1}':\)\([0-9a-f:.]*\).*$/\2/p;q'
+	grep "${2}" | sed -n 's/.*\('"${1}"':\)\([0-9a-f:.]*\).*$/\2/p;q'
 }
 
 # $1: info name ; $2: evts_ns ; $3: event type
 mptcp_lib_evts_get_info() {
-	cat "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
+	mptcp_lib_get_info_value "${1}" "^type:${3:-1}," < "${2}"
 }
Signature · 1 line
2.40.1