C_CYAN='\033[36m' echo -e "\\${C_CYAN}hello";
预期:
\hello
hello
实际:
\033[36mhello
您需要将实际的 ANSI 代码存储在 $C_CYAN 中,而不是其转义版本:
C_CYAN=$'\033[36m' ~