commit 6e9f2c25677285f4b35b43b7d68e7bdac0a4bdc2 Author: Kerin Millar Date: Thu May 28 08:52:03 2026 +0100 phase-helpers.sh: simplify the quoting mechanism of edo() Presently, the edo() function determines whether each parameter merits quoting by: 1) comparing against a hard-coded ERE to check for shell metacharacters 2) comparing against another ERE to ensure all characters are printable Simplify matters by instead going about it in this way: 1) transforming the parameter with printf %q 2) checking whether the transformed parameter matches the original Should the transformed parameter match the original, the original shall be appended to the output string. Otherwise, the original parameter shall be appended to the output string after having been subjected to ${param@Q} expansion. This is the same technique that is employed by gentoo-functions, since v1.7.7. Link: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=7abe8bdd12c1 Signed-off-by: Kerin Millar diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 3d4b4905b..8c8f95e55 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -1230,16 +1230,17 @@ fi if ___eapi_has_edo; then edo() { - # list of special characters taken from sh_contains_shell_metas - # in shquote.c (bash-5.2) - local a out regex='[] '\''"\|&;()<>!{}*[?^$`]|^[#~]|[=:]~' + local out qa a [[ $# -ge 1 ]] || die "edo: at least one argument needed" for a; do # quote if (and only if) necessary - [[ ${a} =~ ${regex} || ! ${a} =~ ^[[:print:]]+$ ]] && a=${a@Q} - out+=" ${a}" + if printf -v qa %q "${a}"; [[ ${qa} == "${a}" ]]; then + out+=" ${a}" + else + out+=" ${a@Q}" + fi done einfon