[PATCH] Squash to "selftests: mptcp: add evts_get_info helper"

Matthieu Baerts posted 1 patch 6 months, 1 week ago
Failed in applying to current master (apply log)
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] Squash to "selftests: mptcp: add evts_get_info helper"
Posted by Matthieu Baerts 6 months, 1 week ago
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.

Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
---

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(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index def35395a254..56cbd57abbae 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -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}"
 }
-- 
2.40.1