diff options
author | P. J. McDermott <pj@pehjota.net> | 2015-10-28 09:49:57 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2015-10-28 09:49:57 (EDT) |
commit | f284655ac148624c98253dcbe1c22590ca0b070b (patch) | |
tree | 39397c56d4c0699667ba05bf6162052cf4c97753 | |
parent | 1a3857c907b5b98097162330b2dc792c39879dd3 (diff) | |
download | firman.sh-f284655ac148624c98253dcbe1c22590ca0b070b.zip firman.sh-f284655ac148624c98253dcbe1c22590ca0b070b.tar.gz firman.sh-f284655ac148624c98253dcbe1c22590ca0b070b.tar.bz2 |
ui/cli: Fix tty output
dbg() calls in flashrom_probe() were writing to a "not a tty" file
because stdin is redirected.
-rw-r--r-- | src/ui/cli.sh | 24 |
1 files changed, 13 insertions, 11 deletions
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 <http://www.gnu.org/licenses/>. +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 |