lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 2d81c4f7 5/8: Simplify


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 2d81c4f7 5/8: Simplify
Date: Fri, 24 Jun 2022 19:56:24 -0400 (EDT)

branch: master
commit 2d81c4f7acfc2942fcefefd70f1b56f633576582
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Simplify
    
    The posix ${parameter:[-=?+]...} substitutions are arcane enough to
    present a barrier to comprehension, yet not powerful enough to perform
    general pattern replacement. The simplest tool that works here is 'sed'.
---
 set_toolchain.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/set_toolchain.sh b/set_toolchain.sh
index 151cc0e3..5ed58ce2 100755
--- a/set_toolchain.sh
+++ b/set_toolchain.sh
@@ -86,6 +86,11 @@
 # That remains the motivation for this design even though i686 builds
 # are no longer supported.
 
+strip_colons()
+{
+    printf '%s' "$1" | sed -e 's/::*/:/g' -e's/::*$//'
+}
+
 foo()
 {
 local   lmi_build_type
@@ -118,8 +123,8 @@ esac
 
 local minimal_path
       minimal_path=${MINIMAL_PATH:-"/usr/bin:/bin:/usr/sbin:/sbin"}
-      minimal_path="${clanggccbindir:+${clanggccbindir}:}""$minimal_path"
-export PATH="$localbindir":"$locallibdir":"$minimal_path"
+export PATH="$localbindir":"$locallibdir":"$clanggccbindir":"$minimal_path"
+PATH=$( strip_colons "$PATH" )
 
 # It is okay to export these variables unconditionally.
 
@@ -151,7 +156,8 @@ case "$lmi_build_type" in
                 LD_LIBRARY_PATH=.
                 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$locallibdir"
                 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$bindir"
-                
LD_LIBRARY_PATH="$LD_LIBRARY_PATH${clanggcclibdir:+:${clanggcclibdir}}"
+                LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$clanggcclibdir"
+                LD_LIBRARY_PATH=$( strip_colons "$LD_LIBRARY_PATH" )
                 # Nullify any leftover "wine" values: obligatorily for
                 # $EXEEXT and $PERFORM, and for $WINEPATH to ensure
                 # that native builds never depend upon it.
@@ -204,4 +210,5 @@ esac
 
 foo
 
+unset -f strip_colons
 unset -f foo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]