Commit 35f9c62d authored by Kelley Reynolds's avatar Kelley Reynolds Committed by Mislav Marohnić
Browse files

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ num_cpu_cores() {
  if [ "Darwin" = "$(uname -s)" ]; then
    num="$(sysctl -n hw.ncpu 2>/dev/null || true)"
  elif [ -r /proc/cpuinfo ]; then
    num="$(grep -c ^processor /proc/cpuinfo)"
    num="$(grep ^processor /proc/cpuinfo | wc -l)"
    [ "$num" -gt 0 ] || num=""
  fi
  echo "${num:-2}"