BTS

Message4094

Author info10
Recipients bugs, info10
Date 2011-12-02.12:02:48
Content
Hello,

in STABLE release of grml I found a bug reproducable with GNU awk 3.1.7 
and 3.1.8. There is this code:

       awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}}
         /address/{if(found){address=$NF}}
         /netmask/{if(found){netmask=$NF}}
         /broadcast/{if(found){broadcast=$NF}}
         /gateway/{if(found){gateway=$NF}}
         /dns-nameservers/{if(found){dns-nameservers=$NF}}
         END{print address" "netmask" "broadcast" "gateway" 
"dns-nameservers}' /etc/network/interfaces >"$TMP"

But when it is executed it fails with:
awk: cmd. line:5:         /dns-nameservers/{if(found){dns-nameservers=$NF}}
awk: cmd. line:5:                                                    ^ 
syntax error

The reason I believe is that character "-" is not allowed in variable 
name in awk. When replacing the code with following, it works correctly:

       awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}}
         /address/{if(found){address=$NF}}
         /netmask/{if(found){netmask=$NF}}
         /broadcast/{if(found){broadcast=$NF}}
         /gateway/{if(found){gateway=$NF}}
         /dns-nameservers/{if(found){dnsnameservers=$NF}}
         END{print address" "netmask" "broadcast" "gateway" 
"dnsnameservers}' /etc/network/interfaces >"$TMP"

Regards,
Marek
-- 

*Marek Malevič*
www.malevic.cz <http://www.malevic.cz>
+420 608 116 896
Files
File name Uploaded
smime.p7s info10, 2011-12-02.12:02:48
unnamed info10, 2011-12-02.12:02:48
History
Date User Action Args
2011-12-02 12:02:49info10setrecipients: + info10
2011-12-02 12:02:49info10linkissue1089 messages
2011-12-02 12:02:48info10create