Hi!

23--2006 10:16 [EMAIL PROTECTED] (Markus Laire) wrote to
freedos-devel@lists.sourceforge.net:

>> All looks fine. How to reproduce bug in FreeCOM with redirection at
>> singlestepping?
ML> I'm able to reproduce this in qemu:

     Oops, sorry. Before patch not accepted yet, let me replace it by
slightly more optimized one.
diff -rup -x config.mak OLD/# NEW/#
--- OLD/#       2006-08-23 00:55:36.000000000 +0000
+++ NEW/#       2006-08-23 17:50:04.000000000 +0000
@@ -158,3 +158,8 @@ Error exec.c 72: Unknown preprocessor di
 
 11. Fixed bug in LFNFUNCS.C library, which prevents redirection (because
     this bug prevents to create non-existed files).
+
+12. Fixed bug with redirection and single-stepping (option /Y) - with nested
+    redirected commands ("if errorlevel 1 echo done>tempout<tempin") FreeCOM
+    was outputs its prompts (for all, except first command) to "tempout" and
+    tries to read answers from "tempin".
diff -rup -x config.mak OLD/shell/command.c NEW/shell/command.c
--- OLD/shell/command.c 2006-08-07 12:17:26.000000000 +0000
+++ NEW/shell/command.c 2006-08-23 18:11:00.000000000 +0000
@@ -382,13 +382,25 @@ void parsecommandline(char *s, int redir
   {                             /* Question after the variables expansion
                                    and make sure _all_ executed commands will
                                    honor the trace mode */
+    /* Commands may be nested ("if errorlevel 1 echo done>test"). To
+       prevent redirecting FreeCOM prompts to user file, temporarily
+       revert redirection.
+    */
+    int redir_fdin, redir_fdout, answer;
+    if (oldinfd  != -1) { redir_fdin  = dup (0); dup2 (oldinfd,  0); }
+    if (oldoutfd != -1) { redir_fdout = dup (1); dup2 (oldoutfd, 1); }
+
     printprompt();
     fputs(s, stdout);
     /* If the user hits ^Break, it has the same effect as
        usually: If he is in a batch file, he is asked if
        to abort all the batchfiles or just the current one */
-       if(userprompt(PROMPT_YES_NO) != 1)
-      /* Pressed either "No" or ^Break */
+    answer = userprompt(PROMPT_YES_NO);
+
+    if (oldinfd  != -1) { dup2 (redir_fdin,  0); close (redir_fdin);  }
+    if (oldoutfd != -1) { dup2 (redir_fdout, 1); close (redir_fdout); }
+
+    if (answer != 1)                           /* "No" or ^Break       */
       return;
   }
 
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to