Description of problem: An directory arg stops processing Version-Release number of selected component (if applicable): gawk-3.1.5-15 How reproducible: Always Steps to Reproduce: 1. In an empty directory ... 2. for f in a c e; do echo >$f; done 3. mkdir b 4. awk --compat '{print FILENAME}' * Actual results: a awk: cmd. line:1: fatal: file `b' is a directory Expected results: a c e Additional info: The existence of a directory might produce a warning on stderr but it certainly shouldn't stop processing of other files. Mainly because it is a HUGE incovenience if you have a directory of 1000 files and one sub-directory and you have to resort to some weird command like: awk '{print FILENAME}' `find . -maxdepth 1 -type f` On SunOS and many other unix's traditional awk silently skips directories, which is very sensible behavior indeed. Because if awk doesn't process a directory (it cannot) and therefore doesn't do anything with it (it cannot) then why should it loudly proclaim an error and completely abort? It is quite safe to continue processing other args because the directory is not affected one way or another. Look at any other programs and see how directories are handled. None of vi, wc, cat, etc completely abort processing just because they encounter a directory. This also happens regardless of use of --compat option. Despite the documentation claiming "... in compatibility mode, gawk behaves identically to UNIX awk ...". That is clearly untrue.
Testing latest released upstream version: Seems like gawk 3.1.6 can be made to continue on directory errors with --disable-directories-fatal configure switch, do we want to build it for RH that way? > This also happens regardless of use of --compat option... Indeed it does in 3.1.5, but 3.1.6 seems to have that fixed. Just tested 3.1.6 with --compat and with --traditional and it works with both - directories are silently ignored.
Indeed, you are right. I will build gawk with --disable-directories-fatal. Note that grep does the same: silently ignores directories.
answering to myself: > Note that grep does the same: silently ignores directories. This was a silly note. Most utilities do complain, try sed -n p /tmp /etc/hosts
The POSIX standard implies the current behaviour. Quoting from http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html#tag_04_06_15: 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. --end of quote-- So, on current GNU/Linux system, where it is not possible to open a directory for reading, awk has not option other then to print an error and immediately quit.