squeeze

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

commit 8bd01a7aa0395916aef93b0e7a2fb5b5728c4df2
parent 357792bce2ad35bad22ac5e9d3ea1ae73ba4270d
Author: St John Karp <contact@stjo.hn>
Date:   Mon, 30 Aug 2021 02:15:39 -0400

Use a portable way to get the number of processors

`nproc` isn't a POSIX tool, but we can use fallbacks to get the
number of processors on different systems.

Diffstat:
Msqueeze.sh | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/squeeze.sh b/squeeze.sh @@ -12,7 +12,11 @@ SOURCE_PATH="$SITE_PATH/source" # A space-separated list of all the process IDs we've started. proc_ids="" # Max number of processes to run at once. -MAX_PROCESSES="$(nproc)" +# 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 || + sysctl -n hw.ncpu 2>/dev/null || + getconf _NPROCESSORS_ONLN 2>/dev/null)" # Copy everything that's not Markdown. # This will also create the folder structure for the destination Markdown files.