From f284655ac148624c98253dcbe1c22590ca0b070b Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 28 Oct 2015 09:49:57 -0400 Subject: ui/cli: Fix tty output dbg() calls in flashrom_probe() were writing to a "not a tty" file because stdin is redirected. --- (limited to 'src') diff --git a/src/ui/cli.sh b/src/ui/cli.sh index 9262cc1..8bc18a1 100644 --- a/src/ui/cli.sh +++ b/src/ui/cli.sh @@ -15,9 +15,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +cli_tty='' + cli_init_ui() { - : Nothing to do. + cli_tty="$(tty)" } cli_exit_ui() @@ -35,7 +37,7 @@ cli_dbg() local fmt="${1}" shift 1 - printf "Debug: ${fmt}\n" "${@}" >"$(tty)" + printf "Debug: ${fmt}\n" "${@}" >"${cli_tty}" } cli_info() @@ -43,7 +45,7 @@ cli_info() local fmt="${1}" shift 1 - printf "${fmt}\n" "${@}" >"$(tty)" + printf "${fmt}\n" "${@}" >"${cli_tty}" } cli_warn() @@ -51,7 +53,7 @@ cli_warn() local fmt="${1}" shift 1 - printf "Warning: ${fmt}\n" "${@}" >"$(tty)" + printf "Warning: ${fmt}\n" "${@}" >"${cli_tty}" } cli_err() @@ -59,7 +61,7 @@ cli_err() local fmt="${1}" shift 1 - printf "Error: ${fmt}\n" "${@}" >"$(tty)" + printf "Error: ${fmt}\n" "${@}" >"${cli_tty}" } cli_show_menu() @@ -70,19 +72,19 @@ cli_show_menu() local l= local label= - printf '%s\n' "${title}" >"$(tty)" - { printf '%s\n' "${title}" | sed 's/./-/g'; } >"$(tty)" + printf '%s\n' "${title}" >"${cli_tty}" + { printf '%s\n' "${title}" | sed 's/./-/g'; } >"${cli_tty}" while :; do - printf '\n' >"$(tty)" + printf '\n' >"${cli_tty}" i=0 l=${#} for label in "${@}"; do i=$(($i + 1)) - printf ' %4d: %s\n' "${i}" "${label}" >"$(tty)" + printf ' %4d: %s\n' "${i}" "${label}" >"${cli_tty}" done - printf '\n> ' >"$(tty)" - if ! read -r i <"$(tty)"; then + printf '\n> ' >"${cli_tty}" + if ! read -r i <"${cli_tty}"; then continue fi case "${i}" in -- cgit v0.9.1