switch in gawk

switch in gawk

Oleg Goldshmidt pub at goldshmidt.org
Sun May 10 22:25:18 IDT 2009


Hi,

I would like to run a tiny and trivial gawk configuration survey. 

Background: I wrote a bunch of gawk scripts lately, and without giving
it much thought I used the switch statement quite liberally. To my
surprise, I found out that

* switch is considered experimental in gawk
* support for switch is not compiled in by default and must be enabled
  at the configure stage with "configure --enable-switch"
* neither CentOS 5.2 nor Fedora 10 have switch support enabled in gawk
* Cygwin's gawk (coming from RedHat as well) has switch enabled

For my purposes I just pulled the gawk sources and compiled it with
--enable-switch. My target platform is mostly Cygwin. However, I
obviously would like to know how (non-)portable an awk script with
switch is.

So, if you have access to the latest RHEL/SLES, or Debian / Ubuntu /
Gentoo / whatever, would you mind running

$ gawk 'END {switch(NR) {default: print NR}}' /dev/null

(or anything with switch that you fancy) and see if it barfs with a
syntax error message or dutifully does what it is supposed to do?

Thanks,

-- 
Oleg Goldshmidt | pub at goldshmidt.org



More information about the Linux-il mailing list