squeeze

A static site generator that can put the toothpaste back in the tube.
git clone https://git.stjo.hn/squeeze
Log | Files | Refs | README | LICENSE

commit b195f00aad1c59e97e204afb7127c53ed0abf50d
parent e7b3e6fa1bfa87c1d1a2f54972c7595493663fe6
Author: St John Karp <contact@stjo.hn>
Date:   Mon, 15 Aug 2022 22:10:59 -0400

Replace call to nproc with grepping /proc/cpuinfo

This change only affects the Linux logic for determining the number
of processors. nproc is not a universal tool but /proc/cpuinfo is
nearly always populated. The BSD fallbacks are unchanged.

Diffstat:
Msqueeze.sh | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/squeeze.sh b/squeeze.sh @@ -29,9 +29,13 @@ proc_ids="" # Max number of processes to run at once. # There is no way to do `nproc` with only POSIX tools, # so the best way to make this portable is with fallbacks. -max_processes="$(nproc 2>/dev/null || +# `nproc` itself isn't even universal on Linux, so the safest +# place to get the number of processors on Linux is /proc/cpuinfo. +max_processes="$( + grep -c ^processor /proc/cpuinfo || sysctl -n hw.ncpu 2>/dev/null || - getconf _NPROCESSORS_ONLN 2>/dev/null)" + getconf _NPROCESSORS_ONLN 2>/dev/null +)" # Regenerate everything if the force flag has been used or there is # no RSS file, but otherwise only regenerate Markdown files that have