Commit 35f9c62d by Kelley Reynolds Committed by Mislav Marohnić

Handle the case when there is no processor info in `/proc/cpuinfo`

`grep -c` would correctly output "0", which is handled specially later
on, but would also exit with a nonzero status which would abort the
script. Piping the output to `wc` to do the counting makes the exit
status of grep irrelevant.

Fixes #447
parent bc9adfdd
...@@ -101,7 +101,7 @@ num_cpu_cores() { ...@@ -101,7 +101,7 @@ num_cpu_cores() {
if [ "Darwin" = "$(uname -s)" ]; then if [ "Darwin" = "$(uname -s)" ]; then
num="$(sysctl -n hw.ncpu 2>/dev/null || true)" num="$(sysctl -n hw.ncpu 2>/dev/null || true)"
elif [ -r /proc/cpuinfo ]; then elif [ -r /proc/cpuinfo ]; then
num="$(grep -c ^processor /proc/cpuinfo)" num="$(grep ^processor /proc/cpuinfo | wc -l)"
[ "$num" -gt 0 ] || num="" [ "$num" -gt 0 ] || num=""
fi fi
echo "${num:-2}" echo "${num:-2}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment