[PATCH] subshell prompt printing fix

Jindrich Novy jnovy at redhat.com
Tue Jun 12 14:17:11 UTC 2007


Hi,

I've been stumbling around this problem for a long time
so I finally decided to fix it.

Bug 1:
1. Have a mc running where you have two different directories
   in each panel.
2. Tab, so that you are in the other panel.
3. Ctrl-O to go to subshell.
4. You see two different prompts printed next to each other.

Bug 2:
1. Have a mc running where you have two different directories
   in each panel.
2. Tab, so that you are in the other panel.
3. Tab, so that you are back.
4. Ctrl-O to go to subshell.
5. You see two same prompts printed next to each other ->
   no prompt printing is desired in this case.

The attached patch fixes both these bugs. The first one completely.
The second one is worked around in the way that the new prompt is
printed on the new line so that the subshell doesn't get messed up.

The question is whether to use Slang calls to reprint the subshell
prompt so that the new line isn't needed to be printed since the
old prompt can be overwritten.

Cheers,
Jindrich

--
Jindrich Novy <jnovy at redhat.com>   http://people.redhat.com/jnovy/
-------------- next part --------------
--- mc-2007-06-04-22/src/main.c.prompt	2007-06-12 15:23:25.000000000 +0200
+++ mc-2007-06-04-22/src/main.c	2007-06-12 15:45:08.000000000 +0200
@@ -453,9 +453,16 @@ do_possible_cd (const char *new_dir)
 void
 do_update_prompt (void)
 {
+    static char *old_subshell_prompt = NULL;
+
     if (update_prompt) {
-	printf ("%s", subshell_prompt);
-	fflush (stdout);
+	if (old_subshell_prompt == NULL
+	    || strcmp (old_subshell_prompt, subshell_prompt)) {
+		g_free (old_subshell_prompt);
+		old_subshell_prompt = g_strdup (subshell_prompt);
+		printf ("\r\n%s", subshell_prompt);
+		fflush (stdout);
+	}
 	update_prompt = 0;
     }
 }


More information about the mc-devel mailing list