From: Disha Goel <disg...@linux.ibm.com>

Running shellcheck on stat+json_output testcase, generates below warning:

         [ $(id -u) != 0 ] && [ $(cat /proc/sys/kernel/perf_event_paranoid) -gt 
$1 ]
           ^------^ SC2046 (warning): Quote this to prevent word splitting.
                                ^-- SC2046 (warning): Quote this to prevent 
word splitting.

Fixed the warning by adding quotes to avoid word splitting.

ShellCheck result with patch:
         # shellcheck -S warning stat+json_output.sh
         #

perf test result after the change:
         94: perf stat JSON output linter : Ok

Signed-off-by: Athira Rajeev <atraj...@linux.vnet.ibm.com>
Signed-off-by: Kajol Jain <kj...@linux.ibm.com>
Signed-off-by: Disha Goel <disg...@linux.ibm.com>
---
 tools/perf/tests/shell/stat+json_output.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/stat+json_output.sh 
b/tools/perf/tests/shell/stat+json_output.sh
index f3e4967cc72e..c19f926a2951 100755
--- a/tools/perf/tests/shell/stat+json_output.sh
+++ b/tools/perf/tests/shell/stat+json_output.sh
@@ -40,7 +40,7 @@ trap trap_cleanup EXIT TERM INT
 # Return true if perf_event_paranoid is > $1 and not running as root.
 function ParanoidAndNotRoot()
 {
-        [ $(id -u) != 0 ] && [ $(cat /proc/sys/kernel/perf_event_paranoid) -gt 
$1 ]
+        [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" 
-gt $1 ]
 }
 
 check_no_args()
-- 
2.39.1

Reply via email to