From c9442bb8a2fa893c3178dcab7635abcb4b5f9310 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Tue, 28 Feb 2017 16:00:32 -0800 Subject: [PATCH] Unset GREP_OPTIONS when extracting processor count If GREP_OPTIONS includes -n or --line-number, matches will be emitted with a line number following the filename. Unset GREP_OPTIONS to ensure we're getting expected output. BUG= R=johnmccutchan@google.com Review-Url: https://codereview.chromium.org/2721953004 . --- runtime/tools/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/tools/utils.py b/runtime/tools/utils.py index 242e6d337ed..595a9ca8edd 100644 --- a/runtime/tools/utils.py +++ b/runtime/tools/utils.py @@ -54,9 +54,9 @@ def GuessArchitecture(): # Try to guess the number of cpus on this machine. def GuessCpus(): if os.path.exists("/proc/cpuinfo"): - return int(commands.getoutput("grep -E '^processor' /proc/cpuinfo | wc -l")) + return int(commands.getoutput("GREP_OPTIONS= grep -E '^processor' /proc/cpuinfo | wc -l")) if os.path.exists("/usr/bin/hostinfo"): - return int(commands.getoutput('/usr/bin/hostinfo | grep "processors are logically available." | awk "{ print \$1 }"')) + return int(commands.getoutput('/usr/bin/hostinfo | GREP_OPTIONS= grep "processors are logically available." | awk "{ print \$1 }"')) win_cpu_count = os.getenv("NUMBER_OF_PROCESSORS") if win_cpu_count: return int(win_cpu_count)