[patch] mutt clearing screen
(resend with appropriate From)
Hello,
I had a friend report that since upgrading mutt (Debian, 1.5.6+20040523i
-> 1.5.9i), they now find that it "clears the screen whenever they exit
mutt".
The problem appears to arise from this call, in init.c:
init.c:2362: if (!option (OPTNOCURSES))
init.c:2363: endwin ();
Unfortunately, I'm not familiar with ncurses, so can't justify it's
presence (or the consequences of removing it). Some fiddling suggests that
the attached patch fixes the problem.
I can reproduce the problem fairly trivially:
1) With no .muttrc file, when exiting, mutt restores the state of the
terminal before execution (i.e. you can see the command that invoked
mutt).
2) With a blank .muttrc file, the terminal is clear on exit (actually says
messages kept and deleted, but that's all). I'm pretty sure this only
happens when there is an invalid line in /etc/Muttrc.
With some further tests, you can see that the screen is actually cleared
on startup rather than initialisation. A consequence is that you can't see
any errors produced by the system-wide file.
Steps (assuming .muttrc exists):
1) Introduce an error to /etc/Muttrc
2) Run mutt. You get told it had errors and press a key to continue. The
screen is blanked at this point.
Further fun/workaround:
1) Create a .muttrc containing a single line:
source /etc/Muttrc
2) Observe that these two commands now produce different states on exit:
mutt
mutt -n
The workaround is thus to source /etc/Muttrc in your .muttrc, and to run
mutt with -n.
The fix is to exit curses mode before printing errors from the /etc/Muttrc
file.
Cheers,
- Simon
--- init.c.orig 2005-07-06 21:33:40.000000000 +1000
+++ init.c 2005-07-06 21:34:24.000000000 +1000
@@ -2168,7 +2168,7 @@
struct passwd *pw;
struct utsname utsname;
char *p, buffer[STRING], error[STRING];
- int i, default_rc = 0, need_pause = 0;
+ int i, default_rc = 0, need_pause = 0, cleared = 0;
BUFFER err;
memset (&err, 0, sizeof (err));
@@ -2383,6 +2383,10 @@
snprintf (buffer, sizeof (buffer), "%s/Muttrc", PKGDATADIR);
if (access (buffer, F_OK) != -1)
{
+ if (!option (OPTNOCURSES)) {
+ endwin ();
+ cleared = 1;
+ }
if (source_rc (buffer, &err) != 0)
{
fputs (err.data, stderr);
@@ -2395,7 +2399,7 @@
/* Read the user's initialization file. */
if (access (Muttrc, F_OK) != -1)
{
- if (!option (OPTNOCURSES))
+ if (!option (OPTNOCURSES) && !cleared)
endwin ();
if (source_rc (Muttrc, &err) != 0)
{