[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Gawk compile error Mingw32
From: |
Vincent Belaïche |
Subject: |
Re: [bug-gawk] Gawk compile error Mingw32 |
Date: |
Sat, 24 Dec 2016 18:05:08 +0100 |
Answers below.
Le 22/12/2016 à 18:46, Eli Zaretskii a écrit :
>> From: address@hidden (Vincent Belaïche)
>> Cc: Vincent Belaïche <address@hidden> ,address@hidden, address@hidden
>> Date: Wed, 21 Dec 2016 17:13:45 +0100
>>
>> $ c:/Users/Vincent/Downloads/gawk-4.1.4-w32-bin/bin/gawk.exe
>> 'END{exit(-1);}' dummy_file.txt; echo $?
>> -| 0
>> $ c:/Users/Vincent/Downloads/gawk-4.1.4-w32-bin/bin/gawk.exe
>> 'END{exit(1);}' dummy_file.txt; echo $?
>> -| 1
>> $ /bin/gawk-3.1.7.exe 'END{exit(-1);}' dummy_file.txt; echo $?
>> -| 255
>> $ /bin/gawk-3.1.7.exe 'END{exit(1);}' dummy_file.txt; echo $?
>> -| 1
>> --8<----8<----8<----8<----8<-- end -->8---->8---->8---->8---->8----
>>
>> Eli's port gawk.exe version 4.1.4 give exit status 0 when meeting
>>
>> --8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
>> END{ exit(-1); }
>> --8<----8<----8<----8<----8<-- end -->8---->8---->8---->8---->8----
>>
>> while MSYS gawk version 3.1.7 gives 255 in that case.
>
> I cannot reproduce this:
>
> D:\gnu\gawk-4.1.4>gawk "END {exit(-1);}" empty_file
>
> D:\gnu\gawk-4.1.4>echo %ERRORLEVEL%
> -1
>
> Are you running this from some Bash? If so, it's the problem with the
> shell you use: it tries to interpret the -1 value in the Unixy way of
> taking just the high 8 bits or somesuch.
>
You are fully right. I did the same trial under an MSDOS console, and
there was not any such issue. I couldn't have ever imagine that the
shell was the one to blame.
> The code in Gawk where we end up when processing the 'exit' statement
> is very simple:
>
> void
> final_exit(int status)
> {
> /* run any extension exit handlers */
> run_ext_exit_handlers(status);
>
> /* we could close_io() here */
> close_extensions();
>
> exit(status);
> }
I did the following even simpler experiment:
--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
// doexit.cpp
#include <cstdio>
#include <cstdlib>
int main(int ac,char const*av[]){
if(ac != 2){
fprintf(stderr,"doexit Expects 1 argument !\n");
return -1;
}
int exit_status = atoi(av[1]);
return exit_status;
}
// Local Variables:
// compile-command: "gcc doexit.cpp -o doexit.exe"
// End:
--8<----8<----8<----8<----8<-- end -->8---->8---->8---->8---->8----
I get the same thing as with gawk.exe when I do
doexit -1; echo $?
I get 0 under bash and when I do
doexit -1
echo %ERRORLEVEL%
then I get -1 under MSDOS console.
>
> and there's nothing on MSDN about any funky interpretation of negative
> return values by the MS runtime.
Sorry for the disturbance. Bye.
Vincent.
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel
antivirus Avast.
https://www.avast.com/antivirus