I don't like the output of more on HP-UX, so I use less instead as a pager:


Its output is nice, but, on Linux, when I use man and then quit, I go back to the shell, and the display looks just the way I left it, but on HP-UX, when I go back to the shell, there is a partial line left before the prompt, much like the following command produces:

echo -e "text \c"

Look at this:

  • on HP-UX:

    user@hpux2:~$ man ls
    Riformattazione in corso. Attendere...user@hpux2:~$

(the message in Italian means "Reformatting in progress, please wait")

  • on Linux:

    user@linux:~$ man ls

How to solve this problem?

  • Do you quit by giving q or using CTRL+C. I have a HPUX machine and it seems to return to the new line ( similar to linux ) if i give q or CTRL+C. I have EDITOR=vi in my environment variables. – rahul May 15 '15 at 19:07
  • Of course q,i have EDITOR=vim,i try also EDITOR=vi but nothing change – elbarna May 15 '15 at 19:28

The screen swapping is done with a terminal control code. Such codes are documented under terminfo(5). The two involved in the screen saving/restoring are typically smcup and rmcup. The first turns on a special cursor addressing mode of the terminal (sm="set mode") and the second one turns it off. Typically, these two will save the screen and restore it.

If screen restoring isn't working, it's possible that those entries are incorrect for your terminal type. You can print the contents of the current terminfo entry using the infocmp command. You'll need to look at those entries (smcup and rmcup) and compare the escape sequences with your terminal manual to determine what they do. Odds are your terminal is just slightly different from the one expected by the terminfo entry.

  • Probably there is some bug with hpux xterm,using dtterm as terminal work fine also for man – elbarna May 18 '15 at 21:27
  • That's a possibility. Sometimes a terminal emulator will claim to be "such-and-such compatible" but leave things out. When the system then defines the terminal type as "such-and-such", the display gets messed up. It could also be that HP's xterm has a special value to be used for TERM and it's not being set properly (maybe a profile changing it?). – Azhrei May 19 '15 at 22:34

The feature mentioned is xterm's alternate screen which was introduced in X.V10R4 (December 1986). Although the feature was supported, it was not added to the terminal description until X11R6 (about ten years).

HPUX's terminal description for xterm happens to be the same as the X11R5 description, with some additions (mainly function keys 1-12). Again, the feature (function keys) had been supported by the program for some time, but was not added to the terminal description.

Here's what infocmp reports for HPUX:

#       Reconstructed via infocmp from file: /usr/share/lib/terminfo/x/xterm
xterm|vs100|xterm terminal emulator,
        am, km, xenl,
        cols#80, lines#65,
        bel=^G, blink=@, bold=\E[1m, civis=\E[?25I,
        clear=\E[H\E[2J, cnorm=\E[?25h, cr=\r,
        csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\b,
        cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
        cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
        cvvis=\E[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
        dl1=\E[M, ed=\E[J, el=\E[K, home=\E[1;1H, ht=\t,
        hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL,
        il1=\E[L, ind=\n, kbs=\177, kcub1=\EOD, kcud1=\EOB,
        kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf10=\E[21~,
        kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR,
        kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
        kf8=\E[19~, kf9=\E[20~, knp=\E[6~, kpp=\E[5~, rc=\E8,
        rev=\E[7m, ri=\EM, rmkx=\E[?1l, rmso=\E[m,
        rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, rs2=@,
        sgr0=\E[m, smkx=\E[?1h, smso=\E[7m, tbc=\E[3g,

Here are links to the X11R6 file, and the X11R3 (unchanged through X11R5). The alternate screen feature in the X11R6 terminal description is provided by this line:

smcup=\E7\E[?47h, rmcup=\E[2J\E[?47l\E8,

With ncurses (Linux, etc), you have a much later terminal description which lists all of the applicable features.

For HPUX, you could fix the problem by using tic to compile a terminal description with the feature added. If you have root access on the HPUX machine, that's simple:

infocmp >foo
vi foo (adding the `smcup` and `rmcup` line)
sudo tic foo

Otherwise, you can work around it by setting the TERMINFOenvironment variable to your own terminfo directory, and runningtic` to compile into that directory. Something like

mkdir -p $TERMINFO/x
tic foo

(you would also need TERMINFO set in your shell for followup sessions).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.