commit:     370e2e82ede07e7699c718d6b984dd0d733657eb
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jun 27 07:21:04 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 28 02:30:22 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=370e2e82

phase-functions.sh: correctly expand the positional parameters for has()

Presently, the __filter_readonly_variables() function makes use of the
has() function to determine whether various GNU-style long options have
been specified. However, it expands the positional parameters as $*,
potentially resulting in word splitting and unwanted pathname expansion.
Address this issue by properly expanding them as "$@", duly rectifying
five instances of SC2048.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/phase-functions.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 860e28b987..b1bfa4a24e 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -121,23 +121,23 @@ __filter_readonly_variables() {
                filtered_vars+=" PORTDIR ECLASSDIR"
        fi
 
-       if has --filter-sandbox $* ; then
+       if has --filter-sandbox "$@"; then
                filtered_vars="${filtered_vars} SANDBOX_.*"
        else
                filtered_vars="${filtered_vars} ${filtered_sandbox_vars}"
        fi
-       if has --filter-features $* ; then
+       if has --filter-features "$@"; then
                filtered_vars="${filtered_vars} FEATURES PORTAGE_FEATURES"
        fi
-       if has --filter-path $* ; then
+       if has --filter-path "$@"; then
                filtered_vars+=" PATH"
        fi
-       if has --filter-locale $* ; then
+       if has --filter-locale "$@"; then
                filtered_vars+=" LANG LC_ALL LC_COLLATE
                        LC_CTYPE LC_MESSAGES LC_MONETARY
                        LC_NUMERIC LC_PAPER LC_TIME"
        fi
-       if ! has --allow-extra-vars $* ; then
+       if ! has --allow-extra-vars "$@"; then
                if [[ "${EMERGE_FROM}" = binary ]]; then
                        # preserve additional variables from build time,
                        # while excluding untrusted variables

Reply via email to