Re: [PATCH] Already running a command



Hi,

I wrote:
> I forgot to remove the comment about subshell state ACTIVE.

These improvements make subshell_ready extern, so we can test if
(subshell_ready == TRUE) in shell_execute() instead of if
(subshell_state == INACTIVE) before calling do_execute(). We should
investigate if subshell_state is perhaps totally redundant.

This improvement should fix oddities with passing keyboard input on the
panel prompt if a subshell is still running (f.e. ls -R | less) with the
previous patch.

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research

src/Changelog:
	subshell.h: Remove unused subshell state ACTIVE.
	Make subshell_ready extern.
	subshell.c (invoke_subshell): Remove bad subshell hack on C-o.
	execute.c (shell_execute): Test on subshell_ready instead of
	subshell_state before invoking do_execute().

--- src/subshell.h.000	2002-12-24 01:13:44.000000000 +0100
+++ src/subshell.h	2004-11-22 03:06:43.000000000 +0100
@@ -14,9 +14,12 @@ extern int use_subshell;
 extern int subshell_pty;
 
 /* State of the subshell; see subshell.c for an explanation */
-enum subshell_state_enum {INACTIVE, ACTIVE, RUNNING_COMMAND};
+enum subshell_state_enum {INACTIVE, RUNNING_COMMAND};
 extern enum subshell_state_enum subshell_state;
 
+/* Subshell finished */
+extern int subshell_ready;
+
 /* Holds the latest prompt captured from the subshell */
 extern char *subshell_prompt;
 
--- src/subshell.c.000	2004-11-07 13:42:53.000000000 +0100
+++ src/subshell.c	2004-11-22 03:05:08.000000000 +0100
@@ -99,7 +99,6 @@ static const char subshell_switch_key = 
 
 /* State of the subshell:
  * INACTIVE: the default state; awaiting a command
- * ACTIVE: remain in the shell until the user hits `subshell_switch_key'
  * RUNNING_COMMAND: return to MC when the current command finishes */
 enum subshell_state_enum subshell_state;
 
@@ -128,7 +135,7 @@ static char subshell_cwd[MC_MAXPATHLEN+1
 static enum {BASH, TCSH, ZSH} subshell_type;
 
 /* Flag to indicate whether the subshell is ready for next command */
-static int subshell_ready;
+int subshell_ready;
 
 /* The following two flags can be changed by the SIGCHLD handler. This is */
 /* OK, because the `int' type is updated atomically on all known machines */
@@ -528,13 +528,7 @@ int invoke_subshell (const char *command
     
     if (command == NULL)  /* The user has done "C-o" from MC */
     {
-	if (subshell_state == INACTIVE)
-	{
-	    subshell_state = ACTIVE;
-	    /* FIXME: possibly take out this hack; the user can
-	       re-play it by hitting C-hyphen a few times! */
-	    write (subshell_pty, " \b", 2);  /* Hack to make prompt reappear */
-	}
+	;
     }
     else  /* MC has passed us a user command */
     {
--- src/execute.c.000	2004-09-15 09:38:10.000000000 +0200
+++ src/execute.c	2004-11-22 03:03:29.000000000 +0100
@@ -176,7 +176,7 @@ shell_execute (const char *command, int 
 {
 #ifdef HAVE_SUBSHELL_SUPPORT
     if (use_subshell)
-	if (subshell_state == INACTIVE)
+	if (subshell_ready == TRUE)
 	    do_execute (shell, command, flags | EXECUTE_AS_SHELL);
 	else
 	    message (1, MSG_ERROR,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]