Re: [dev] a few questions about watch in ubase

From: Ryan Wilson <>
Date: Thu, 21 Apr 2016 15:48:10 -0500

 ---- On Thu, 21 Apr 2016 13:04:43 -0500 Greg Reagle <> wrote ----

> Is it appropriate to use ANSI escape codes in the program rather than
> using something like tput or terminfo, or to just execute the "clear"
> command? Are the escape codes portable?

clear(1) from ncurses also clears the scrollback buffer if the terminal
supports it (see the manpage), that's not what you'd want here. As for
portability, tput clear does `^[[2J^[[H` for basically everything:

    # List the value of `tput clear` for everything in /usr/share/terminfo:
    for T in $(toe -a | cut -f1);
        do printf "%-40.s%s\n" "tput -T $T clear" "$(tput -T $T clear | cat -v)";

The only terminals where it's not some variation on `^[[2J^[[H` are ancient and
obscure. But hey, it looks like the Apple II didn't support it (cf. infocmp appleII),
so if you're trying to run watch there you may be disappointed.
Received on Thu Apr 21 2016 - 22:48:10 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 21 2016 - 23:00:14 CEST