libstd.bash: use reference variable in std:prepend_path() not upvar

This commit is contained in:
2022-05-24 10:13:19 +02:00
parent 25c302d91c
commit bd0efa648b
+8 -9
View File
@@ -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() {