Fulcrum/contrib/base.sh
Mave95 72bffa5994
fixed arithmetic expansion in a shell script (#70)
Message from submitter:

Build failed on my Debian Buster machine, because WORKER_COUNT was assigned a string of $CPU_COUNT+1

---

Note from Calin:

I was unable to reproduce his problem, but since his new fix and old fix produce equivalent results for me, and he
claims his way fixes something for him, merging.
2020-12-12 08:30:44 +02:00

19 lines
480 B
Bash

#!/bin/sh
set -e
if [ -z "$CPU_COUNT" ] ; then
# CPU_COUNT is not set, try to detect the core count
case $(uname) in
Linux)
export CPU_COUNT=$(lscpu | grep "^CPU(s):" | awk '{print $2}')
;;
Darwin)
export CPU_COUNT=$(sysctl -n hw.ncpu)
;;
esac
fi
# If CPU_COUNT is still unset, default to 4
export CPU_COUNT="${CPU_COUNT:-4}"
# Use one more worker than core count
export WORKER_COUNT=$(($CPU_COUNT+1))