[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug] close() returns "0" when closing unopened files
From: |
Seb |
Subject: |
Re: [bug] close() returns "0" when closing unopened files |
Date: |
Sat, 6 Dec 2008 13:43:50 +0100 |
Le Thu, 04 Dec 2008 22:42:36 +0200
Aharon Robbins <address@hidden> a écrit:
> You have found a bug! Thanks for the bug report. The following
> patch fixes the problem and will be showing up in the gawk-stable CVS
> tree shortly.
Thanks! it works perfectly for me... :)
Oh! I forgot to notice that the returned values of close() are not documented
in the manual. Maybe it could be useful, while it is a good way to test if an
information isn't available because this one is not in the parsed file or
because the file just does not exist. Here is an example (adapted for the
manual, if you want ;):
BEGIN {
found = 0
while ((getline line < "BBS-list") > 0) {
if (match(line, /^sabafoo/)) {
found++
break
}
}
if ((close("BBS-list")) < 0) {
print "Error: the \"BBS-list\" file does not exist!"
exit 1
}
print (found > 0) ? "sabafoo is in the list!" : "sabafoo is not in the
list!"
exit 0
}
++
Seb.