From bd0efa648ba4163eb7591eae3b1f0ff56cfe014b Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 24 May 2022 10:13:19 +0200 Subject: [PATCH] libstd.bash: use reference variable in std:prepend_path() not upvar --- Pmodules/libstd.bash | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Pmodules/libstd.bash b/Pmodules/libstd.bash index b39cced..cbe2121 100644 --- a/Pmodules/libstd.bash +++ b/Pmodules/libstd.bash @@ -91,25 +91,24 @@ std::append_path () { } std::prepend_path () { - local -r P="$1" + local -nr P="$1" shift 1 - local new_path="$1" + local path="$1" shift 1 local dir - if [[ -z ${!P} ]]; then + if [[ -z ${P} ]]; then for dir in "$@"; do - new_path+=":${dir}" + path+=":${dir}" done - export "$P=${new_path}" + P="${path}" else for dir in "$@"; do - [[ "${!P}" == @(|*:)${dir}@(|:*) ]] && continue - new_path+=":${dir}" + [[ "${P}" == @(|*:)${dir}@(|:*) ]] && continue + path+=":${dir}" done - new_path+=":${!P}" + P="${path}:${P}" fi - std::upvar "$P" "${new_path}" } std::remove_path() {