bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: gawk bug when calling system()


From: Manuel Collado
Subject: Re: gawk bug when calling system()
Date: Tue, 22 Jul 2008 18:10:01 +0200
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Eli Zaretskii escribió:
Date: Tue, 22 Jul 2008 09:36:08 -0400
From: Aharon Robbins <address@hidden>
Cc: address@hidden

Hi. This is cc'ed to the bug list so that perhaps someone else can find
the problem. (And bcc'ed to the gawk Windows maintainer.)

The issue is that under Windows, current gawk

        gawk 'BEGIN { print system("exit 11") }'

doesn't print the correct exit status.

I think that's because awk.h has this snippet:

    #ifndef WEXITSTATUS
    #define WEXITSTATUS(stat_val) ((((unsigned) (stat_val)) >> 8) & 0xFF)
    #endif

It does the wrong thing for Windows, since the status there is not
returned in the top 8 bits, but rather begins at the LSB.  I just
tried

   gawk "BEGIN { print system (\"exit 512\") }"

on Windows, and sure thing, it printed 2.

Well, it depends on the particular Windows port of gawk:

- the DJGPP port (3.1.6) prints 0
- the MinGW port (3.1.6) prints 2
- the Cygwin port (3.1.5) prints 512

Al least for my installed versions.
--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado





reply via email to

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