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

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

Re: [bug?] getline is not fatal when posix is forced


From: Aharon Robbins
Subject: Re: [bug?] getline is not fatal when posix is forced
Date: Sun, 30 Nov 2008 23:35:02 +0200

Hi. You have found a bug in the documentation.  I'm not sure why I thought
getline in posix mode on a non-existant or unreadable file was fatal,
but neither mawk, nawk, nor gawk treat it that way.

I will double check the standard, but I think the documentation is just
wrong and I'll fix it.

Thanks!

Arnold

> Date: Sun, 30 Nov 2008 13:10:09 +0100
> From: Seb <address@hidden>
> To: address@hidden
> Subject: [bug?] getline is not fatal when posix is forced
>
> Hello,
>
> I've been learning awk, and searching for a way to test if a file exists (and 
> is
> readable, of course), I found this section in the gawk manual :
>
>   http://www.gnu.org/software/gawk/manual/gawk.html#File-Checking
>
> It is said at the end that execute the getline function on a non-readable file
> should be fatal to the program in a POSIXLY correct context. But when I try to
> test this behaviour (I'd like my scripts to be a little bit portable), I don't
> get any fatal error:
>
> $ echo '1' > /tmp/none
>
> $ gawk 'BEGIN { i=0; while ((getline < "/tmp/none")> 0){ print "Exists
> and is readable." }; close("/tmp/none"); print "Program continues..." }'
> Exists and is readable.
> Program continues...
>
> $ gawk --posix 'BEGIN { i=0; while ((getline < "/tmp/none")> 0){ print "Exists
> and is readable." }; close("/tmp/none"); print "Program continues..." }'
> Exists and is readable.
> Program continues...
>
> $ rm -f /tmp/none
>
> $ gawk 'BEGIN { i=0; while ((getline < "/tmp/none")> 0){ print "Exists
> and is readable." }; close("/tmp/none"); print "Program continues..." }'
> Program continues...
>
> $ gawk --posix 'BEGIN { i=0; while ((getline < "/tmp/none")> 0){ print "Exists
> and is readable." }; close("/tmp/none"); print "Program continues..." }'
> Program continues...
>
> Is there something wrong with the gawk POSIX handle, or does the manual just
> need to be updated (or did I miss something :) ?
>
> Thanks,
> Seb.




reply via email to

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