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

Eric Blake eblake at redhat.com
Wed Apr 21 22:52:30 UTC 2010


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100421/15aa01f2/attachment-0001.sig>


More information about the libvir-list mailing list