lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master b44f960 3/5: Generally prefer printf to echo


From: Greg Chicares
Subject: [lmi-commits] [lmi] master b44f960 3/5: Generally prefer printf to echo
Date: Fri, 31 May 2019 19:23:49 -0400 (EDT)

branch: master
commit b44f960088ed06fda26a93735c26042f1e14caba
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Generally prefer printf to echo
    
    Removed a comment that incorrectly said shell builtins mustn't be used
    in a script that is to be sourced. That was an improper generalization
    of the actual truth that a zsh-specific builtin like 'print' mustn't be
    used in a script that is to be sourced by dash; OTOH, POSIX builtins
    like 'printf' are okay.
---
 set_toolchain.sh | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/set_toolchain.sh b/set_toolchain.sh
index 2cab34f..8433747 100755
--- a/set_toolchain.sh
+++ b/set_toolchain.sh
@@ -135,16 +135,15 @@ case "$lmi_build_type" in
 esac
 if [ -n "$LMI_ENV_FILE" ]; then
     {
-    echo "export PATH     := $PATH"
-    echo "export WINEPATH := $WINEPATH"
-    echo "export PERFORM  := $PERFORM"
+    printf '%s\n' "export PATH     := $PATH"
+    printf '%s\n' "export WINEPATH := $WINEPATH"
+    printf '%s\n' "export PERFORM  := $PERFORM"
     } > "$LMI_ENV_FILE"
 fi
 }
 
-# This script is to be sourced, so it can't use a builtin command like
-# 'printf' here. Similarly, 'exit' would have a surprising effect.
-# Therefore, these precondition checks use 'echo' and 'return'.
+# This script is to be sourced, so use 'return' because 'exit' would
+# have a surprising effect.
 
 export LMI_COMPILER
 export LMI_TRIPLET
@@ -154,7 +153,7 @@ export LMI_TRIPLET
 case "$LMI_COMPILER" in
     (gcc) ;;
     (*)
-        echo "Changed nothing because compiler '$LMI_COMPILER' is untested."
+        printf '%s\n' "Changed nothing because compiler '$LMI_COMPILER' is 
untested."
         return 2;
         ;;
 esac
@@ -163,7 +162,7 @@ case "$LMI_TRIPLET" in
     (i686-w64-mingw32)   ;;
     (x86_64-w64-mingw32) ;;
     (*)
-        echo "Changed nothing because host triplet '$LMI_TRIPLET' is untested."
+        printf '%s\n' "Changed nothing because host triplet '$LMI_TRIPLET' is 
untested."
         return 3;
         ;;
 esac



reply via email to

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