echo: ensure output goes to stdout/stderr

all of these echo helpers are essentially 'logging' functions with output
always intended for stdout/stderr. lack of explicit stdout/stderr direction
means that their output could be captured unintentionally should they be
used within a function designed to construct a string.

Gbp-Dch: Short
Closes: #952879
This commit is contained in:
Lyndon Brown 2020-03-01 02:54:18 +00:00 committed by Luca Boccassi
parent b8e3a27324
commit e3a987d977
1 changed files with 27 additions and 27 deletions

View File

@ -13,7 +13,7 @@ Echo ()
STRING="${1}" STRING="${1}"
shift shift
printf "${STRING}\n" "${@}" printf "${STRING}\n" "${@}" >&1
} }
Echo_debug () Echo_debug ()
@ -23,7 +23,7 @@ Echo_debug ()
STRING="${1}" STRING="${1}"
shift shift
printf "D: ${STRING}\n" "${@}" printf "D: ${STRING}\n" "${@}" >&1
fi fi
} }
@ -34,13 +34,13 @@ Echo_debug_running ()
STRING="${1}" STRING="${1}"
shift shift
printf "D: ${STRING}" "${@}" printf "D: ${STRING}" "${@}" >&1
if [ "${_COLOR}" = "false" ] if [ "${_COLOR}" = "false" ]
then then
printf "..." printf "..." >&1
else else
printf "... ${YELLOW}${BLINK}running${NO_COLOR}" printf "... ${YELLOW}${BLINK}running${NO_COLOR}" >&1
fi fi
fi fi
} }
@ -69,12 +69,12 @@ Echo_message ()
if [ "${_COLOR}" = "false" ] if [ "${_COLOR}" = "false" ]
then then
printf "P:" printf "P:" >&1
else else
printf "${WHITE}P${NO_COLOR}:" printf "${WHITE}P${NO_COLOR}:" >&1
fi fi
printf " ${STRING}\n" "${@}" printf " ${STRING}\n" "${@}" >&1
fi fi
} }
@ -87,18 +87,18 @@ Echo_message_running ()
if [ "${_COLOR}" = "false" ] if [ "${_COLOR}" = "false" ]
then then
printf "P:" printf "P:" >&1
else else
printf "${WHITE}P${NO_COLOR}:" printf "${WHITE}P${NO_COLOR}:" >&1
fi fi
printf " ${STRING}" "${@}" printf " ${STRING}" "${@}" >&1
if [ "${_COLOR}" = "true" ] if [ "${_COLOR}" = "true" ]
then then
printf "... ${YELLOW}${BLINK}running${NO_COLOR}" printf "... ${YELLOW}${BLINK}running${NO_COLOR}" >&1
else else
printf "..." printf "..." >&1
fi fi
fi fi
} }
@ -110,7 +110,7 @@ Echo_verbose ()
STRING="${1}" STRING="${1}"
shift shift
printf "I: ${STRING}\n" "${@}" printf "I: ${STRING}\n" "${@}" >&1
fi fi
} }
@ -121,13 +121,13 @@ Echo_verbose_running ()
STRING="${1}" STRING="${1}"
shift shift
printf "I: ${STRING}" "${@}" printf "I: ${STRING}" "${@}" >&1
if [ "${_COLOR}" = "true" ] if [ "${_COLOR}" = "true" ]
then then
printf "... ${YELLOW}${BLINK}running${NO_COLOR}" printf "... ${YELLOW}${BLINK}running${NO_COLOR}" >&1
else else
printf "..." printf "..." >&1
fi fi
fi fi
} }
@ -139,12 +139,12 @@ Echo_warning ()
if [ "${_COLOR}" = "false" ] if [ "${_COLOR}" = "false" ]
then then
printf "W:" printf "W:" >&1
else else
printf "${YELLOW}W${NO_COLOR}:" printf "${YELLOW}W${NO_COLOR}:" >&1
fi fi
printf " ${STRING}\n" "${@}" printf " ${STRING}\n" "${@}" >&1
} }
Echo_status () Echo_status ()
@ -155,18 +155,18 @@ Echo_status ()
then then
if [ $__RETURN -eq 0 ] if [ $__RETURN -eq 0 ]
then then
printf " done.\n" printf " done.\n" >&1
else else
printf " failed.\n" printf " failed.\n" >&1
fi fi
else else
Cursor_columns_backward 8 Cursor_columns_backward 8
if [ $__RETURN -eq 0 ] if [ $__RETURN -eq 0 ]
then then
printf " ${GREEN}done${NO_COLOR}. \n" printf " ${GREEN}done${NO_COLOR}. \n" >&1
else else
printf " ${RED}failed${NO_COLOR}.\n" printf " ${RED}failed${NO_COLOR}.\n" >&1
fi fi
fi fi
} }
@ -175,11 +175,11 @@ Echo_done ()
{ {
if [ "${_COLOR}" = "false" ] if [ "${_COLOR}" = "false" ]
then then
printf " already done.\n" printf " already done.\n" >&1
else else
Cursor_columns_backward 8 Cursor_columns_backward 8
printf " ${GREEN}already done${NO_COLOR}.\n" printf " ${GREEN}already done${NO_COLOR}.\n" >&1
fi fi
} }
@ -187,7 +187,7 @@ Echo_file ()
{ {
while read LINE while read LINE
do do
echo "${1}: ${LINE}" echo "${1}: ${LINE}" >&1
done < "${1}" done < "${1}"
} }