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

Re: [libvirt] [PATCH] portability fixes to tools/virt-pki-validate.in



On 04/21/2010 03:52 PM, Dustin Kirkland wrote:
> -ORG=`$CERTOOL -i --infile $CA/cacert.pem | grep Issuer | sed 's+Issuer: CN=++'`
> -if [ "$ORG" == "" ]
> +ORG=`$CERTOOL -i --infile $CA/cacert.pem | grep Issuer | sed -e 's+\s*Issuer: .*CN=++' -e 's+,EMAIL=.*++'`

Using \s in sed is not portable; I'm not even sure what it was supposed
to match to help rewrite it to something in POSIX, since I don't see it
documented in 'info sed'.

> -        if [ "`grep '^LIBVIRTD_ARGS' $(SYSCONFDIR)/sysconfig/libvirtd | grep -- '--listen'`" = "" ]
> +        if ! grep -qs "^LIBVIRTD_ARGS.*--listen" "$SYSCONFDIR"/sysconfig/libvirtd

'if !' is not portable to Solaris /bin/sh.  And 'grep -qs' is not
portable.  A better rewrite would be:

if grep "^LIBVIRTD_ARGS.*--listen" "$SYSCONFDIR"/sysconfig/libvirtd \
    >/dev/null 2>&1 ; then
    :
else
    echo ...
fi

> -        if [ "`grep $PORT $(SYSCONFDIR)/sysconfig/iptables`" = "" ]
> +        if ! grep -qs $PORT "$SYSCONFDIR"/sysconfig/iptables

Likewise:

if grep $PORT "$SYSCONFDIR"/sysconfig/iptables >/dev/null 2>&1 ; then
    :
else
    echo ...
fi

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
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]