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

Re: [libvirt] [PATCH] Don't require gawk for a simple print expression



On 08/28/2012 01:57 AM, Guido Günther wrote:
> Fedora uses gawk as awk so there's no change and in behavior while
> Debian/Ubuntu use mawk by default.
> 
> This was reported by Luca Capello in
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=636712
> ---
>  src/nwfilter/nwfilter_ebiptables_driver.c |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

ACK.  I confirmed that our only use of awk was for the simple script
'{print $1}', so this patch is a good quick fix.

But down the road, I would welcome a patch to simplify
iptablesLinkIPTablesBaseChain() to avoid gawk altogether.  Right now, we
are using gawk to split out the first field of $($IPT -L $chain -n
--line-number | grep " $chain "); but the shell is already sufficient to
split out a whitespace separated field.  That is, instead of:

r=$(echo $res | $awk '{print $1}')
if [ "${r}" != "$pos" ]; then

we could use:

set dummy $res
r=$2
if [ "$r" != "$pos" ]; then

provided that we audit that the rest of our generated shell script
output doesn't care that we overwrote positional arguments with set.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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