summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-04-17 10:18:31 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-04-17 10:18:31 -0400
commit2838fd4a4e7fa40dd9cd95c81eb852190371ec5a (patch)
tree6cf8af9dd8da5802a76c418bac02087cdd82c24b
parent83bfed52e523ef942da82a083584a4548182aaa4 (diff)
downloadbfs-2838fd4a4e7fa40dd9cd95c81eb852190371ec5a.tar.xz
build: Make the config scripts POSIX-compliant
-rw-r--r--Makefile2
-rwxr-xr-xconfig/cc.sh2
-rwxr-xr-xconfig/pkg.sh8
-rwxr-xr-xconfig/pkgconf.sh22
4 files changed, 18 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index e9efef3..f42c59b 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ config::
# Direct users to the new configuration system.
asan lsan msan tsan ubsan gcov lint release::
@printf 'error: `%s %s` is no longer supported. ' "${MAKE}" $@ >&2
- @printf 'Use `%s config %s=y` instead.\n' "${MAKE}" $$(echo $@ | tr '[a-z]' '[A-Z]') >&2
+ @printf 'Use `%s config %s=y` instead.\n' "${MAKE}" $$(echo $@ | tr 'a-z' 'A-Z') >&2
@false
# Print an error if `make` is run before `make config`
diff --git a/config/cc.sh b/config/cc.sh
index abce508..e6883f5 100755
--- a/config/cc.sh
+++ b/config/cc.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD
diff --git a/config/pkg.sh b/config/pkg.sh
index 2ca533e..4ebea64 100755
--- a/config/pkg.sh
+++ b/config/pkg.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD
@@ -7,10 +7,10 @@
set -eu
-NAME="${1^^}"
-declare -n XUSE="USE_$NAME"
+NAME=$(printf '%s' "$1" | tr 'a-z' 'A-Z')
+eval "XUSE=\"\${USE_$NAME:-}\""
-if [ "${XUSE:-}" ]; then
+if [ "$XUSE" ]; then
USE="$XUSE"
elif config/pkgconf.sh "$1"; then
USE=y
diff --git a/config/pkgconf.sh b/config/pkgconf.sh
index 361852e..d6c45c7 100755
--- a/config/pkgconf.sh
+++ b/config/pkgconf.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD
@@ -8,20 +8,22 @@
set -eu
MODE=
-if [[ "${1:-}" == --* ]]; then
- MODE="$1"
- shift
-fi
+case "${1:-}" in
+ --*)
+ MODE="$1"
+ shift
+esac
-if (($# < 1)); then
+if [ $# -lt 1 ]; then
exit
fi
-if [[ "$XNOLIBS" == [y1] ]]; then
- exit 1
-fi
+case "$XNOLIBS" in
+ y|1)
+ exit 1
+esac
-if command -v "${XPKG_CONFIG:-}" &>/dev/null; then
+if command -v "${XPKG_CONFIG:-}" >/dev/null 2>&1; then
case "$MODE" in
"")
"$XPKG_CONFIG" "$@"