Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
printf and tput can also be used to handle the coloring without worrying about the backslash issue. tput is a command that can be used to set terminal attributes, including colors, and it handles e...
#1: Initial revision
`printf` and `tput` can also be used to handle the coloring without worrying about the backslash issue. `tput` is a command that can be used to set terminal attributes, including colors, and it handles escape sequences more _cleanly_. ```bash printf "%s$(tput setaf 9)NOTE$(tput sgr0)\n" "${var}" ``` This avoids the problem of backslashes being misinterpreted and works regardless of the content of `$var`.