summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-07-01 17:55:34 +1000
committerMike Kaganski <mike.kaganski@collabora.com>2019-07-02 02:54:39 +0200
commit19724cb7f886cbcc60cd8a1f5e6eda6fdca41155 (patch)
tree9d44a29cac4a95edfc6947b86b89d7dbe7b39219 /configure.ac
parent6be961a7b6b5594b65f651522ef19f38bb9579aa (diff)
Improve pathmunge to properly detect/cleanup duplicates
E.g. on Windows, I see three duplicated paths in the resulting PATH, so this aims to make PATH tidy. Change-Id: If553eefe278f442dbe44c73ca955e481b5cabd63 Reviewed-on: https://gerrit.libreoffice.org/74947 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac30
1 files changed, 24 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index f7683b0350e8..3aefd18cd107 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2367,6 +2367,26 @@ if test "$libo_fuzzed_enable_dbus" = yes -a "$libo_fuzzed_enable_avahi" -a \
enable_avahi=$enable_dbus
fi
+add_lopath_after ()
+{
+ if ! echo "$LO_PATH" | $EGREP -q "(^|${P_SEP})$1($|${P_SEP})"; then
+ LO_PATH="${LO_PATH:+$LO_PATH$P_SEP}$1"
+ fi
+}
+
+add_lopath_before ()
+{
+ local IFS=${P_SEP}
+ local path_cleanup
+ local dir
+ for dir in $LO_PATH ; do
+ if test "$dir" != "$1" ; then
+ path_cleanup=${path_cleanup:+$path_cleanup$P_SEP}$dir
+ fi
+ done
+ LO_PATH="$1${path_cleanup:+$P_SEP$path_cleanup}"
+}
+
dnl ===================================================================
dnl check for required programs (grep, awk, sed, bash)
dnl ===================================================================
@@ -2385,12 +2405,10 @@ pathmunge ()
else
new_path="$1"
fi
- if ! echo "$LO_PATH" | $EGREP -q "(^|:)$1($|:)"; then
- if test "$2" = "after"; then
- LO_PATH="$LO_PATH${P_SEP}$new_path"
- else
- LO_PATH="$new_path${P_SEP}$LO_PATH"
- fi
+ if test "$2" = "after"; then
+ add_lopath_after "$new_path"
+ else
+ add_lopath_before "$new_path"
fi
unset new_path
fi