commit: 4d72028326dfea6d8360dad441e80cd52cafb5b9
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Aug 11 17:47:25 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 17 16:16:17 2024 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=4d720283
Abort sourcing for ksh93
In the case of ksh93, the commonly implemented behaviour of "local" can
be approximated with "typeset". However, to use typeset in this way
requires the use of the function f { ...; } syntax instead of the
POSIX-compatible f() compound-command syntax. As things stand, there is
no sense in allowing for functions.sh to be sourced by ksh93.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
functions.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/functions.sh b/functions.sh
index 1c8721f..b618054 100644
--- a/functions.sh
+++ b/functions.sh
@@ -24,6 +24,7 @@
# GENFUN_MODULES : which of the optional function collections must be sourced
# IFS : warn() operands are joined by its first character
# INVOCATION_ID : used by from_unit()
+# KSH_VERSION : used to detect ksh93, which is currently unsupported
# PORTAGE_BIN_PATH : used by from_portage()
# POSIXLY_CORRECT : if unset/empty, quote_args() may emit dollar-single-quotes
# RC_OPENRC_PID : used by from_runscript()
@@ -42,6 +43,12 @@ warn()
printf '%s: %s\n' "${0##*/}" "$*" >&2
}
+case ${KSH_VERSION} in 'Version AJM 93'*)
+ # The ksh93 shell has a typeset builtin but no local builtin.
+ warn "gentoo-functions does not currently support ksh93"
+ return 1
+esac
+
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"