summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2025-04-17 19:30:58 -0400
committerTavian Barnes <tavianator@tavianator.com>2025-04-17 19:30:58 -0400
commit16649a99898b2739f4eb313ec156f3218809da20 (patch)
tree7e6bca7edc36d78d8db16eb154ab77603bc8d9d6
parent7102fec257835302cb4978160bba4cbebd0b63e1 (diff)
downloadbfs-16649a99898b2739f4eb313ec156f3218809da20.tar.xz
configure: Work around a Bash 3 bug
Before Bash 4, the `command` builtin did not work properly in AND-OR lists when set -e was active, leading to set -e command nonesuch || echo none failing without echoing. Work around it by runing `command nproc` in a subshell. Link: https://stackoverflow.com/q/68143965
-rwxr-xr-xconfigure4
1 files changed, 3 insertions, 1 deletions
diff --git a/configure b/configure
index 1842078..ab62aa6 100755
--- a/configure
+++ b/configure
@@ -87,7 +87,9 @@ invalid() {
# Get the number of cores to use
nproc() {
{
- command nproc \
+ # Run command nproc in a subshell to work around a bash 3 bug
+ # https://stackoverflow.com/q/68143965
+ (command nproc) \
|| sysctl -n hw.ncpu \
|| getconf _NPROCESSORS_ONLN \
|| echo 1