make-w32
[Top][All Lists]
Advanced

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

Re: Make CVS (Win32) improperly leaves batch files with -n


From: Eli Zaretskii
Subject: Re: Make CVS (Win32) improperly leaves batch files with -n
Date: Sat, 18 Feb 2006 20:31:42 +0200

> Date: Tue, 14 Feb 2006 22:09:49 +0200
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden
> 
> > From: "J. David Bryan" <address@hidden>
> > Date: Mon, 13 Feb 2006 19:55:22 -0500
> > 
> > Running the current CVS version under Windows with the "-n" (--dry-run) 
> > option against the following example makefile:
> > 
> > 
> > all:
> >         @echo hello
> >         @echo there
> > 
> > 
> > ...will leave two batch files in the TEMP directory each time it is run.  
> > Running without -n properly cleans up the files.
> 
> Thanks, I will look into fixing this.

The patches below fix this problem.  They also fix another small
blunder: the temporary batch file, when it was created, was written in
binary mode, so it had Unix-style LF-only line endings.  This works
with cmd.exe from modern Windows versions, but would fail with
command.com that is the shell on Windows 9x.  Oops!

2006-02-18  Eli Zaretskii  <address@hidden>

        * job.c (construct_command_argv_internal): Don't create a
        temporary script/batch file if we are under -n.  Call _setmode to
        switch the script file stream to text mode.

--- job.c~4     2006-01-21 21:37:14.812500000 +0200
+++ job.c       2006-02-18 20:18:17.546875000 +0200
@@ -2767,7 +2767,9 @@ construct_command_argv_internal (char *l
     /* Some shells do not work well when invoked as 'sh -c xxx' to run a
        command line (e.g. Cygnus GNUWIN32 sh.exe on WIN32 systems).  In these
        cases, run commands via a script file.  */
-    if ((no_default_sh_exe || batch_mode_shell) && batch_filename_ptr) {
+    if (just_print_flag)
+      ;        /* nothing */
+    else if ((no_default_sh_exe || batch_mode_shell) && batch_filename_ptr) {
       int temp_fd;
       FILE* batch = NULL;
       int id = GetCurrentProcessId();
@@ -2782,7 +2784,8 @@ construct_command_argv_internal (char *l
 
       /* Create a FILE object for the batch file, and write to it the
         commands to be executed.  */
-      batch = _fdopen (temp_fd, "w");
+      _setmode (temp_fd, _O_TEXT); /* _fdopen doesn't switch to O_TEXT! */
+      batch = _fdopen (temp_fd, "wt");
       if (!unixy_shell)
         fputs ("@echo off\n", batch);
       fputs (command_ptr, batch);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]