switch in gawk

switch in gawk

Shlomi Fish shlomif at iglu.org.il
Sun May 10 22:43:45 IDT 2009


On Sunday 10 May 2009 22:25:18 Oleg Goldshmidt wrote:
> 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?
>

On Mandriva Cooker (updated today):

{{{{{{{{{{{{{{
shlomi:~$ gawk 'END {switch(NR) {default: print NR}}' /dev/null
gawk: END {switch(NR) {default: print NR}}
gawk:                 ^ syntax error
shlomi:~$
}}}}}}}}}}}}}}

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Why I Love Perl - http://xrl.us/bjn88

God gave us two eyes and ten fingers so we will type five times as much as we
read.




More information about the Linux-il mailing list