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

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

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


From: Seb
Subject: [bug?] getline is not fatal when posix is forced
Date: Sun, 30 Nov 2008 13:10:09 +0100

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]