[issue1089] netcardconfig bug

Marek Malevic bts at bts.grml.org
Fri Dec 2 13:02:49 CET 2011


New submission from Marek Malevic <info at malevic.cz>:

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: smime.p7s, unnamed
messages: 4094
nosy: info10
status: unread
title: netcardconfig bug

_____________________________________
GRML issue tracker <bts at bts.grml.org>
<http://bts.grml.org/grml/issue1089>
_____________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ml.grml.org/pipermail/bugs-changes/attachments/20111202/14cee1bb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5908 bytes
Desc: not available
URL: <http://ml.grml.org/pipermail/bugs-changes/attachments/20111202/14cee1bb/attachment.bin>


More information about the Bugs-changes mailing list