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: Andrew J. Schorr
Subject: Re: [gawk-stable] bug: fatal error when getline from directory
Date: Mon, 5 Jan 2009 08:54:43 -0500
User-agent: Mutt/1.4.2.2i

On Mon, Jan 05, 2009 at 01:35:03AM +0100, Paolo wrote:
> But it must not *abort* the script, there's no (portability/anything else)
> reason to not let the script go on and handle the exception the way the
> programmer has devised. Think bash(1), what if 'set -e' were the
> unmodifiable default?

I hate to jump into the middle of a flame war, but it does seem
wrong to me that calling getline would abort the script.  I'm not
making a standards-based argument, just expressing my intuitive
sense of how getline should work.  IMHO, the point of getline is to allow
the script to exert more control over the processing of the data
files, and to be able to deal with errors.  A fatal abort deprives
the program of the opportunity to handle errors gracefully.

That being said, a workaround would be to install xgawk
and do something like this:

   xgawk -lfilefuncs -v "fn=/tmp" '
BEGIN {
   if ((stat(fn,st) < 0) || (st["type"] == "directory"))
      printf "oops, cannot access %s\n",fn > "/dev/stderr"
   else
      print (getline x < fn)
}'

Regards,
Andy




reply via email to

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