From 364746528f55a84c683dfb0e80a30a1b649fdd64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20M=C3=BCller?= Date: Tue, 25 May 2021 17:59:13 +0200 Subject: [PATCH] Ban nameref variables from exported and default scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nameref variables will break detection of Bash arrays. The default src_prepare() has this test: [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]] If PATCHES is a name reference and its target is an array, then declare -p will _not_ resolve the indirection, but output "declare -n" instead. We could work around this by updating the test to: ( unset "PATCHES[1]" 2>/dev/null ) using the fact that unset will return an error status when applied to an element (other than the zeroth) of a scalar variable. However, this looks like a very hackish solution which could break with future Bash versions. Bug: https://bugs.gentoo.org/636652 Signed-off-by: Ulrich Müller --- ebuild-format.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ebuild-format.tex b/ebuild-format.tex index 4929ba4..3f45242 100644 --- a/ebuild-format.tex +++ b/ebuild-format.tex @@ -11,6 +11,8 @@ compatibility settings (e.\,g.\ the \t{BASH_COMPAT} variable) are not exported t option of bash is set in the global scope of ebuilds. If set, failed pattern matches during filename expansion result in an error when the ebuild is being sourced. +Name reference variables (introduced in Bash version~4.3) must not be used, except in local scope. + The file encoding must be UTF-8 with Unix-style newlines. When sourced, the ebuild must define certain variables and functions (see chapters~\ref{ch:ebuild-vars} and~\ref{ch:ebuild-functions} for specific information), and must not call any external programs, write anything to standard -- 2.31.1