[Top][All Lists]

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

Re: Win32 command exit status code via $$?

From: Paul D. Smith
Subject: Re: Win32 command exit status code via $$?
Date: Fri, 14 Oct 2005 18:23:52 -0400

%% Dale Thomas <address@hidden> writes:

  dt> Does anyone know if there is a problem with the 3.81beta3 for Win32

There may well be, but your example doesn't show one... :-)

  dt> all:
  dt>      date > foo.text
  dt>      @echo $$?

  dt> I would expect the echo to output 0 if date succeeded and > 0 otherwise
  dt> All that is output is $?

Er... well, first, this won't work because GNU make, as it has always
done, invoke every line of the command script in a different shell.  So,
you cannot echo $?, the result of the first command, in the second line
because it's running in a different shell.

You'd need to put both on the same line:

            date > foo.text ; echo $$?

Second, in your example if the date command exits with a non-0 code the
second line will never be invoked at all: make will see that the first
shell exited with an error and not run the rest of the command script.
So, it won't print anything if date fails.

In this way your example and my alternative behave differently: my
alternative will print something every time AND exit with a success code
every time (unless echo fails, which I don't think it ever does).

  dt> This works fine on OSX with the 3.80

I say it doesn't, for the reasons I cite above.  I expect you included
here a small sample rather than the real code, and didn't test it
thoroughly to make sure it exhibited the same behavior as the real code
it was modeled on.

As for your _basic_ problem, that it print "$?", that's probably because
on Windows you don't have a UNIX shell: you are using Windows
COMMAND.COM or similar.  That has an _entirely_ different syntax.
You'll either need to get a UNIX-y shell on Windows, or rewrite your
command scripts to use COMMAND.COM operations.


 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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