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

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

Re: [gawk-stable] bug: fatal error when getline from directory


From: Eric Blake
Subject: Re: [gawk-stable] bug: fatal error when getline from directory
Date: Sun, 04 Jan 2009 17:06:16 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Paolo on 1/4/2009 4:25 PM:
> On Sun, Jan 04, 2009 at 07:58:13AM -0700, Eric Blake wrote:
> ...
>> That definition carries over into POSIX 2008, pretty much unchanged:
> 
> same as the text I quoted @bottom in my msg

You quoted POSIX 2001, which has been changed in some respects (but not
this one) to become POSIX 2008.

> Eg, /dev/random isn't such a text file, yet POSIX awk can read open it; 

POSIX does not require awk to be able to read /dev/random.  You are
outside the realm of POSIX if you feed a non-text file to awk.  The fact
that gawk handles it nicely is intentional, but we would also be
POSIX-compliant by making gawk reformat your hard drive when you hand it a
non-text file.

> $ rd
> fd=3
> EOF

Your example is OS-dependent, and does not behave that way on other OS's.

>> POSIX.  You did not give gawk a text file in this example, but gawk went
> 
> so? should it have complained with "fatal: '-' is not a text file"?

We very well could have; once you leave the realm of POSIX, you have no
guarantees on what we will or won't do, unless we document that, as an
extension to POSIX, we behave in a particular manner.

> nope, seems you didn't get my point: it's wrong to *abort* script just 
> because getline stumbled on an unreadable/unknown file/entity/whatever; 
> the specs only requires that awk bails out on file *operands* error:
> 
> "CONSEQUENCES OF ERRORS
> 
>     If any file operand is specified and the named file cannot be accessed,
>     awk shall write a diagnostic message to standard error and terminate 
>     without any further action."

You didn't get my point.  Once you pass a non-text file to awk, you have
left the realm of what POSIX requires (since POSIX requires that you only
pass text files in).  Therefore, we are not even required to issue a
diagnostic (although consistency demands that it would be a nice thing to do).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklhTvgACgkQ84KuGfSFAYBxugCdGzu6ViWJX3UMZSQtOvwcwfFU
LsIAn25pqenuiObOFL8LfRznEYD78j8a
=kG+C
-----END PGP SIGNATURE-----




reply via email to

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