selftests: ftrace: Check given string is not zero-length
authorMasami Hiramatsu <mhiramat@kernel.org>
Fri, 7 Jul 2017 01:03:36 +0000 (10:03 +0900)
committerShuah Khan <shuahkh@osg.samsung.com>
Wed, 26 Jul 2017 21:41:43 +0000 (15:41 -0600)
Use [ ! -z "$VAR" ] instead of [ "$VAR" ] to check
whether the given string variable is not zero-length
since it obviously shows what it means.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Steven Rostedt (VMware) <srostedt@goodmis.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/ftrace/ftracetest

index cce1a0c26daf5c98df363e30a18aaadcd51dfeae..abc706cf7702629e8b8ce1f12d352cd362e797cf 100755 (executable)
@@ -8,7 +8,7 @@
 # Released under the terms of the GPL v2.
 
 usage() { # errno [message]
-[ "$2" ] && echo $2
+[ ! -z "$2" ] && echo $2
 echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
 echo " Options:"
 echo "         -h|--help  Show help message"
@@ -50,7 +50,7 @@ parse_opts() { # opts
   local OPT_TEST_CASES=
   local OPT_TEST_DIR=
 
-  while [ "$1" ]; do
+  while [ ! -z "$1" ]; do
     case "$1" in
     --help|-h)
       usage 0
@@ -96,7 +96,7 @@ parse_opts() { # opts
     ;;
     esac
   done
-  if [ "$OPT_TEST_CASES" ]; then
+  if [ ! -z "$OPT_TEST_CASES" ]; then
     TEST_CASES=$OPT_TEST_CASES
   fi
 }