Fix grep command. It was raising an exception if the grep did
       not succeed. This was caused by passing the ignore_status argument
       only by position to utils.system, which was broken when somebody
       added timeout=

       >>> autotest_utils.grep ('Linux', '/etc/motd')
       True
       >>> autotest_utils.grep ('ffffffffff', '/etc/motd')
       Traceback (most recent call last):
          ...

       Now (and should be)

       >>> autotest_utils.grep('Linux', '/etc/motd')
       True
       >>> autotest_utils.grep('Linuxs', '/etc/motd')
       False

Signed-off-by: Martin J. Bligh <mbigh@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2129 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index ae0cc13..b0be65d 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -33,20 +33,23 @@
     equivalent to 'cat file | command' but knows to use
     zcat or bzcat if appropriate
     """
+    if not os.path.isfile(file):
+        raise NameError('invalid file %s to cat to command %s'
+                % (file, command))
+
     if return_output:
         run_cmd = utils.system_output
     else:
         run_cmd = utils.system
 
-    if not os.path.isfile(file):
-        raise NameError('invalid file %s to cat to command %s'
-                % (file, command))
     if file.endswith('.bz2'):
-        return run_cmd('bzcat ' + file + ' | ' + command, ignore_status)
+        cat = 'bzcat'
     elif (file.endswith('.gz') or file.endswith('.tgz')):
-        return run_cmd('zcat ' + file + ' | ' + command, ignore_status)
+        cat = 'zcat'
     else:
-        return run_cmd('cat ' + file + ' | ' + command, ignore_status)
+        cat = 'cat'
+    return run_cmd('%s %s | %s' % (cat, file, command),
+                                                    ignore_status=ignore_status)
 
 
 def extract_tarball_to_dir(tarball, dir):