| tests: fix color output using printf instead of echo Purpose/Problem: Shell scripts use ANSI escape codes like \033[0;32m for colored output, but plain 'echo' does NOT interpret these sequences - they are printed as literal text. This results in output like \033[0;32m[TEST]\033[0m instead of colored [TEST]. Solution: 1. Use 'printf %b' which reliably interprets escape sequences across all POSIX shells (unlike 'echo -e' which is bash-specific) 2. Auto-detect tty in set_color_names() - disable colors when output is piped/redirected (non-tty context) 3. Provide unified color_print(), log(), error(), skip() functions in common.sh that scripts can reuse or override Changes: - tests/common.sh: add tty detection in set_color_names() - tests/common.sh: add color_print() helper function - all test scripts: replace 'echo "\${GREEN}..."' with 'printf %b' Benefits: - Colors work correctly on terminal - No color codes clutter when output is piped/redirected - POSIX-compliant, works across bash/dash/ash/etc Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn> | 3 个月前 |