commit: 9550ec3e9bbb6ffa996db5c4da889413588f7689 Author: Kerin Millar <kfm <AT> plushkava <DOT> net> AuthorDate: Sun Aug 11 17:02:50 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Fri Aug 16 06:36:53 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=9550ec3e
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 <AT> plushkava.net> functions.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/functions.sh b/functions.sh index 733e4e9..1c8721f 100644 --- a/functions.sh +++ b/functions.sh @@ -30,9 +30,24 @@ # 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 @@ -705,14 +720,6 @@ trueof_any() false } -# -# 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
