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

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

GAWK 3.1.0 Windows NT versus Unix


From: Jim Sievers
Subject: GAWK 3.1.0 Windows NT versus Unix
Date: Thu, 8 Aug 2002 17:27:54 -0400

Would like some clarification on a problem that I discovered using GAWK on
both Unix and Windows NT

Unix version works flawlessly and meets standard documentation

Windows NT version does not appear to be returning status codes from the
SYSTEM() command properly

For example:
If you are using the GNU TEST.EXE command (GNU shellutils 1.9.4) under
Windows NT as follows:

        1. Execute:    test -d baddirectory      {Directory that does not
exist}
        2. Execute:    if errorlevel 1 echo Yes

        Obviously, it will echo Yes. Repeat the same test but replace
baddirectory with a directory that does exist
        and it will not return Yes because the directory was found. The test
utility is properly returning status codes

Build a simple GAWK program test.awk as follows:

        BEGIN {
                status=system("c:\\test -d baddirectory")
                if (status == 0)
                           print "True return"
                else
                           print "False return"
        }

        1. Execute:     gawk -f test.awk
        2. Edit test.awk and change baddirectory to a valid directory
        3. Execute:     gawk -f test.awk

        It always prints "True return" even though the first test should
have printed "False Return"
        If you execute the same test on Unix (changing c:\\test -d
baddirectory to just /home/test -d baddirectory)
        everything works properly.

Is there something about environment or DLL's that are not matching up?
I have quite a bit of tested/debugged Unix GAWK code that takes advantage of
return status codes to operate properly
Simply trying to port to Windows environment with obvious changes to command
line structure and nothing seems to
work.

A standard ANSI C program appears to work just fine and it calls the same
GNU test utility

#include <stdlib.h>
#include <stdio.h>

int main(argc,argv)
int argc;
char *argv[];
{
        int status;

        status=system("c:\\test -d baddirectory");
        if (status == 0)
           printf("True return");
        else
           printf("False return");
        return 0;
}

Your feedback on how to solve the problem would be appreciated
Thanks!
-Jim

James Sievers
Professional Services Engineer
Harbor Technologies
9000H Commerce Parkway
Mt. Laurel, NJ 08054
Email: address@hidden
Office: 856-222-0643 x1067




reply via email to

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