ProgrammersOfVilnius / pov-check-health

Debian package that runs basic system health monitoring checks hourly from cron
https://launchpad.net/~pov/+archive/ppa
2 stars 0 forks source link

Avoid unportable use of echo #3

Closed mgedmin closed 9 years ago

mgedmin commented 9 years ago

If you source functions.sh in bash, set verbose=1 and attempt to use info_check Checking something in a terminal that supports colors, you'll see a bunch of escape sequences instead of terminal output codes.

This happens because echo \033 is undefined behavior, according to POSIX. dash interprets it by echoing a single ASCII ESC character, bash prints the four ASCII characters (BACKSLASH ZERO THREE THREE) literally.

printf, which is a shell builtin in both bash and dash, is well-specified and interprets C-style escape sequences. Using it instead of echo would make it possible to make use of functions.sh when /bin/sh is set to bash.