From 5541d3e3856ba2ef7071a480b49dbef3321c64a5 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 14 Dec 2007 12:16:05 +0000 Subject: [PATCH] We should only do colours if fd1 is a terminal by default --- sh/functions.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sh/functions.sh b/sh/functions.sh index 00828f54..4c8843e8 100644 --- a/sh/functions.sh +++ b/sh/functions.sh @@ -171,8 +171,18 @@ for arg; do esac done -if [ -z "${GOOD}" ] && yesno ${EINFO_COLOR:-YES}; then - eval $(eval_ecolors) +if [ -t 1 ] && yesno "${EINFO_COLOR:-YES}"; then + if [ -z "${GOOD}" ]; then + eval $(eval_ecolors) + fi +else + # We need to have shell stub functions so our init scripts can remember + # the last ecmd + for _e in ebegin eend error errorn einfo einfon ewarn ewarnn ewend \ + vebegin veend veinfo vewarn vewend; do + eval "${_e}() { local _r; /lib/rc/bin/${_e} \"\$@\"; _r=$?; \ + export EINFO_LASTCMD=${_e}; return \$_r; }" + done fi # vim: set ts=4 :