Bug 11126

Summary: Bash Shell Programming using Buildroot
Product: buildroot Reporter: umamahesh <umamahesh.y>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: major CC: buildroot, vapier
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description umamahesh 2018-06-30 17:27:15 UTC
Hi


I am running bash shell scripts on raspberry pi target using Buildroot environment and I am trying to enable colours in bash shell programming for output using tput command but in buildroot it seems to be not supported.


Please suggest alternate option to enable colours.


For example,


I am writing following in the shell script


echo "$(tput setaf 2) $(tput bold) $(tput smso) LINUX PERFORMANCE TEST $(tput rmso) $(tput sgr 0)"


and in the target it says

 perf_test_1.sh: line 8: tput: command not found


Please suggest.
Comment 1 Tibor Stolz 2019-02-01 12:31:19 UTC
Hi umamahesh,

If this is still relevant, here is the solution.

"tput" is part of the ncurses package. To enable it, go to:

make menuconfig
    Target packages
        Libraries
            Text and terminal handling

Enable "ncurses", then enable the "ncurses programs" entry that has just appeared.

Help for the "ncurses programs" entry:
BR2_PACKAGE_NCURSES_TARGET_PROGS:
Include ncurses programs in target (clear, reset, tput, ...)

Best regards,
Tibor Stolz
Comment 2 Tibor Stolz 2019-02-01 12:38:21 UTC
Another solution is to program directly with escape sequences:

echo -e '\E[32;1;7m LINUX PERFORMANCE TEST \E[0m'

echo -ne '\E[32;1;7m'
echo -n "LINUX PERFORMANCE TEST"
echo -e '\E[0m'

This will work on the Linux console and terminal emulators like xterm.

See "help echo" and "man console_codes"-->"ECMA-48 Set Graphics Rendition" on your host Linux system.

Best regards,
Tibor Stolz