summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-08-11 18:02:50 +0100
committerKerin Millar <kfm@plushkava.net>2024-08-16 07:36:53 +0100
commit9550ec3e9bbb6ffa996db5c4da889413588f7689 (patch)
tree8db41601f4899afdb7a551eb1368f753d15aadd3
parentmeosn.build: prepare for gentoo-functions-1.7.2 (diff)
downloadgentoo-functions-9550ec3e9bbb6ffa996db5c4da889413588f7689.tar.gz
gentoo-functions-9550ec3e9bbb6ffa996db5c4da889413588f7689.tar.bz2
gentoo-functions-9550ec3e9bbb6ffa996db5c4da889413588f7689.zip
Abort sourcing for yash in posixlycorrect mode
The yash shell takes conformance so seriously that it goes as far as to disable the local builtin in its posixlycorrect mode. https://magicant.github.io/yash/doc/posix.html $ yash -o posixlycorrect -c 'f() { local var; }; f' yash: local: non-portable built-in is not supported in the POSIXly-correct mode Signed-off-by: Kerin Millar <kfm@plushkava.net>
-rw-r--r--functions.sh23
1 files changed, 15 insertions, 8 deletions
diff --git a/functions.sh b/functions.sh
index 733e4e9..1c8721f 100644
--- a/functions.sh
+++ b/functions.sh
@@ -30,10 +30,25 @@
# SENTINEL : can define a value separating two distinct argument lists
# SYSTEMD_EXEC_PID : used by from_unit()
# TERM : used to detect dumb terminals
+# YASH_VERSION : for detecting yash before checking for incompatible options
#------------------------------------------------------------------------------#
#
+# Prints a diagnostic message prefixed with the basename of the running script.
+#
+warn()
+{
+ printf '%s: %s\n' "${0##*/}" "$*" >&2
+}
+
+if [ "${YASH_VERSION}" ] && set +o | grep -qxF 'set -o posixlycorrect'; then
+ # The yash shell disables the local builtin in its POSIXly-correct mode.
+ warn "gentoo-functions does not support yash in posixlycorrect mode"
+ return 1
+fi
+
+#
# Considers the first parameter as a reference to a variable by name and
# assigns the second parameter as its value. If the first parameter is found
# not to be a legal identifier, no assignment shall occur and the return value
@@ -706,14 +721,6 @@ trueof_any()
}
#
-# Prints a diagnostic message prefixed with the basename of the running script.
-#
-warn()
-{
- printf '%s: %s\n' "${0##*/}" "$*" >&2
-}
-
-#
# Considers the first parameter as a command name before trying to locate it as
# a regular file. If not specified as an absolute pathname, a PATH search shall
# be performed in accordance with the Environment Variables section of the Base