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

awk and fflush()/-W interactive



In panel.sh we use "awk -W interactive '... { ... fflush(); }'.

This confused some users (at least someone in IRC), because on nearly
all awk versions, this will echo something like "option `-W
interactive' unrecognized, ignored" to stdout (but still work, because
-W interactive and fflush() do the same).

Out of curiosity, I did some tests to verify which awk supports what:

Version               -W interactive     fflush()
==================================================
gawk 3.1.8            ignored (warning)  supported
gawk 4.1.0            ignored (warning)  supported
mawk 1.3.4 20130219   supported          supported
oawk (Solaris)        error              error
awk 19990602 (plan9)  ignored (warning)  supported
busybox v1.21.1 awk   ignored (warning)  supported
awk 20070501 (OS X)   ignored (warning)  supported

So there are two possible fixes for the annoying warning on stderr:

 - Redirect stderr to /dev/null

   But then, as Thorsten noticed with my bash scripts patch, if
   anyone really uses an awk which doesn't support fflush(), they
   won't get an error message, which is suboptimal.

 - Drop the "-W interactive"

   According to #awk on Freenode, only mawk and gawk support -W (and
   gawk only supports -W, not -W interactive) -- and they both also
   support fflush().

   To me, it seems "-W interactive" is a mawk-specific way if you're
   too lazy to fflush() yourself and want linebuffered output.

Am I missing anything? Are there any awk versions which DON'T support
fflush(), but DO support "-W interactive"? #awk doesn't seem to think
so. So IMHO, we could avoid the confusing message and just drop the
"-W interactive".

Opinions? Thorsten, would you be okay when I add that to my reworked
shell patch?

Florian

-- 
www.the-compiler.org | Top-posting sucks! http://s.cmpl.cc/top
  I love long mails! | http://email.is-not-s.ms/
With a rubber duck, one's never alone. -- "The Hitchhiker's Guide to the 
Galaxy" 

Attachment: pgpO7GtNEuSMx.pgp
Description: PGP signature