Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/ftrace: Handle the absence of tput

In environments where tput is not available, we get the following
error
$ ./ftracetest: 163: [: Illegal number:
because ncolors is an empty string. Fix that by setting it to 0 if the
tput command fails.

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Signed-off-by: Shuah Khan <shuah@kernel.org>

authored by

Juerg Haefliger and committed by
Shuah Khan
0e27ded1 4ce55a9c

+2 -2
+2 -2
tools/testing/selftests/ftrace/ftracetest
··· 154 154 155 155 # Define text colors 156 156 # Check available colors on the terminal, if any 157 - ncolors=`tput colors 2>/dev/null` 157 + ncolors=`tput colors 2>/dev/null || echo 0` 158 158 color_reset= 159 159 color_red= 160 160 color_green= 161 161 color_blue= 162 162 # If stdout exists and number of colors is eight or more, use them 163 - if [ -t 1 -a "$ncolors" -a "$ncolors" -ge 8 ]; then 163 + if [ -t 1 -a "$ncolors" -ge 8 ]; then 164 164 color_reset="\033[0m" 165 165 color_red="\033[31m" 166 166 color_green="\033[32m"