#618332 rxvt-unicode: screen contents not restored when detaching a "screen" session

Package:
screen
Source:
screen
Description:
terminal multiplexer with VT100/ANSI terminal emulation
Submitter:
Vincent Lefevre
Date:
2024-03-22 15:33:02 UTC
Severity:
normal
#618332#5
Date:
2011-03-14 11:56:42 UTC
From:
To:
The screen contents are not restored when detaching a "screen" session.
To reproduce the problem:

1. Run rxvt-unicode.
2. Run some commands, just to generate contents in the screen.
3. Run the "screen" utility.
4. Detach the "screen" session ([Cmd key] d), or simpler: terminate
   the shell (this will close the session and quit screen).

The bug: The contents one had before running "screen" are not restored.

I don't have this problem with xterm, aterm or gnome-terminal.

#618332#10
Date:
2011-03-14 14:22:27 UTC
From:
To:
The problem is that screen fails to enable the alternate screen buffer
in urxvt. This happens because screen sends "is2" after "smcup", and is2
disables the alternate screen buffer. The problem does not occur in
xterm because xterm's is2 does not disable the alternate screen buffer.

#618332#15
Date:
2011-03-14 14:51:21 UTC
From:
To:
Thanks for the information.

Isn't there any standard about is2?

Is it a bug in rxvt-unicode, ncurses-base (which provides
/lib/terminfo/r/rxvt-unicode, but perhaps following recommendations
by rxvt-unicode developers) or screen (which sends "is2")?

Even if one considers that screen does something bad and should be
fixed, the incompatibility between rxvt-unicode and other terminals
(xterm, gnome-terminal) can be annoying.

#618332#20
Date:
2011-03-14 15:07:18 UTC
From:
To:
Marc changed is2 in 9.06 with the following rationale

"redundantly clear mouse reporting and a few other states in tput
init/tput reset, for older urxvts"

but I cannot remember what exactly prompted this change.

#618332#25
Date:
2011-03-14 20:27:29 UTC
From:
To:
Well, the terminfo manpage says it initialises the terminal, and that is2
usually does most of that work, but that doesn't matter, as they are all
taken together (there are multiple ones so you can split very long init
sequences, there is no semantic difference between is1, is2 etc.).

Almost certainly screen - ncurses programs do the right thing and don't
reset the terminal *after* configuring it.

I don't know what screen tries to accomplish, but if it wants a clean
state, then it needs to output all the intiialisation sequences *before*
configuring the terminal, as obviously configuration can be lost when
intiialisaing the terminal.

And if screen outputs is2 but not the other sequences as required by
terminfo, that's an even bigger wtf. There is no reason to do so, and that
*will* break things.

Hmm, which incompatibility is there?

"tput init" is the canonical way to bring your terminal into a clean state
after a curses program (or screen, which loves to crash...) crashed. The
change just implemented that.

#618332#34
Date:
2011-03-15 03:09:19 UTC
From:
To:
screen doesn't reset the terminal after configuring it. This can be
seen with xterm and gnome-terminal.

Perhaps. It seems to make sense. However the terminfo(5) man page
doesn't document that it should be done in this order.

I don't know what screen does exactly, but

  tput smcup
  tput init
  tput rmcup

works in xterm, but not in rxvt-unicode. This may be the problem
with screen.

See above. Unless the above sequence is incorrect...

No, this is "tput reset" that brings the terminal into a clean state.
"tput init" doesn't do that in at least two major terminals: xterm
and gnome-terminal.

#618332#39
Date:
2018-12-11 12:48:19 UTC
From:
To:
Hello! In Debian 9 terminal content is not restored even in xterm. I
work around the problem with the following trick:

In .screenrc I completely removed ti/te:

termcapinfo xterm*|rxvt* 'ti=:te='

I run screen wrapped with tput calls:

tput smcup; screen -S test; tput rmcup

This works quite good except for commands that make screen to write to
terminal like -ls or -Q: the final tput hides the text. So I wrote a
screen wrapper in shell:

#! /bin/sh

if [ "$1" = "-ls" -o "$1" = "--list" ]; then
   list=true
fi

test "$list" = true || tput smcup
/usr/bin/screen "$@"
test "$list" = true || tput rmcup

Now it's near perfect. Tested with rxvt and xterm.

Oleg.

#618332#44
Date:
2018-12-11 21:17:25 UTC
From:
To:
This will hide error messages. For instance:

$ tput smcup; screen -r does_not_exist; tput rmcup

#618332#49
Date:
2024-03-22 14:09:17 UTC
From:
To:
Control: found -1 4.8.0-6
Control: found -1 4.9.0-4
Control: found -1 4.9.1-1

The bug no longer occurs in rxvt-unicode 9.31-3 from Debian/unstable,
but it still occurs in rxvt-unicode 9.30-2 from Debian 12 (stable).

#618332#60
Date:
2024-03-22 14:59:31 UTC
From:
To:
Actually it still occurs in rxvt-unicode 9.31-3 from Debian/unstable.
I might have done something wrong.

#618332#65
Date:
2024-03-22 15:29:02 UTC
From:
To:
Control: forwarded -1 https://savannah.gnu.org/bugs/?65506

and I've just reported the bug upstream (GNU Screen).