From 9028999da58d500490ae972a79dbc676322ea7c1 Mon Sep 17 00:00:00 2001 From: gsell Date: Tue, 4 Feb 2025 16:26:04 +0100 Subject: [PATCH] Merge branch '386-libstd-bugs-in-std-append_path-and-std-prepend_path' into '1.1.22' Resolve "libstd: bugs in std::append_path() and std::prepend_path()" See merge request Pmodules/src!412 (cherry picked from commit e0841bce3971e490d67684d66ab66b1579a0ef73) a3ee63cf libstd (#386): bugfixes in std::append_path(), std::prepend_path() Co-authored-by: gsell --- Pmodules/libstd.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pmodules/libstd.bash b/Pmodules/libstd.bash index 9a24b45..b90e4f8 100644 --- a/Pmodules/libstd.bash +++ b/Pmodules/libstd.bash @@ -285,6 +285,7 @@ std::append_path () { [[ "${path}" == @(|*:)${dir}@(|:*) ]] && continue dirs+="${dir}:" done + [[ -n "${dirs}" ]] || return 0 # assemble new path dirs="${dirs%:}" # remove leading ':' @@ -308,12 +309,13 @@ std::prepend_path () { [[ "${path}" == @(|*:)${dir}@(|:*) ]] && continue dirs+="${dir}:" done + [[ -n "${dirs}" ]] || return 0 # assemble new path dirs="${dirs%:}" # remove leading ':' if [[ -z ${path} ]]; then path="${dirs}" - else + else path="${dirs}:${path}" fi }