diff options
| author | Michał Górny <mgorny@gentoo.org> | 2024-02-07 17:39:18 +0100 |
|---|---|---|
| committer | Michał Górny <mgorny@gentoo.org> | 2024-02-10 11:47:21 +0100 |
| commit | 5fcce58386dfb317020d7c88478480592b98b4e4 (patch) | |
| tree | f19a8e79b0b7a7c5e755260c64aa331e6a0636dc /eclass/llvm-utils.eclass | |
| parent | 118145de3992a8249131bd0eb30ea89ad0bd0bdf (diff) | |
| download | gentoo-5fcce58386dfb317020d7c88478480592b98b4e4.tar.gz gentoo-5fcce58386dfb317020d7c88478480592b98b4e4.tar.bz2 gentoo-5fcce58386dfb317020d7c88478480592b98b4e4.zip | |
llvm-utils.eclass: Fix llvm_prepend_path to avoid duplicates
Fix llvm_prepend_path() not to append the new path multiple times,
if the original PATH variable contained multiple LLVM directories.
Thanks to Alexander Miller who spotted it in:
https://github.com/gentoo/gentoo/pull/35196#discussion_r1480330001
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/llvm-utils.eclass')
| -rw-r--r-- | eclass/llvm-utils.eclass | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/eclass/llvm-utils.eclass b/eclass/llvm-utils.eclass index f308667e3dc2..532e609679b8 100644 --- a/eclass/llvm-utils.eclass +++ b/eclass/llvm-utils.eclass @@ -129,16 +129,18 @@ llvm_prepend_path() { local new_path=() local x added= - # prepend new path in front of the first LLVM version found for x in "${split_path[@]}"; do if [[ ${x} == */usr/lib/llvm/*/bin ]]; then - if [[ ${x} != ${llvm_path} ]]; then + # prepend new path in front of the first LLVM version found + if [[ ! ${added} ]]; then new_path+=( "${llvm_path}" ) - elif [[ ${added} && ${x} == ${llvm_path} ]]; then + added=1 + fi + # remove duplicate copies of the same path + if [[ ${x} == ${llvm_path} ]]; then # deduplicate continue fi - added=1 fi new_path+=( "${x}" ) done |
