[virt-tools-list] [PATCH] grep -q Portability

Richard Laager rlaager at wiktel.com
Mon Aug 8 20:42:18 UTC 2011


I don't think I've sent this one to the list yet.

The nc -q autodetection code fails if the target system's grep does not
have a -q argument (quite the ironic coincidence). I believe -q is
specified by POSIX, but Solaris 11's /bin/grep does not support -q.
Redirecting to /dev/null works portably. (In fact, this is even
recommended in favor of -q for portability by GNU grep's man page.)

This needs to be changed in virt-manager's src/virtManager/console.py.

Richard

diff --git a/src/virtManager/console.py b/src/virtManager/console.py
index 1bdf26b..5fa9fe1 100644
--- a/src/virtManager/console.py
+++ b/src/virtManager/console.py
@@ -93,7 +93,7 @@ class Tunnel(object):
             nc_params = "%s %s" % (gaddr, gport)
 
         nc_cmd = (
-            """nc -q 2>&1 | grep -q "requires an argument";"""
+            """nc -q 2>&1 | grep "requires an argument" >/dev/null;"""
             """if [ $? -eq 0 ] ; then"""
             """   CMD="nc -q 0 %(nc_params)s";"""
             """else"""

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20110808/e20d90c3/attachment.sig>


More information about the virt-tools-list mailing list