lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master c9fe5f53 2/2: Check /dev/tty before writing t


From: Greg Chicares
Subject: [lmi-commits] [lmi] master c9fe5f53 2/2: Check /dev/tty before writing to it
Date: Wed, 18 Jan 2023 19:37:11 -0500 (EST)

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

    Check /dev/tty before writing to it
    
    The immediately preceding commit dealt with messages that are to be
    printed to stdout and also to /dev/tty, e.g.:
      -echo "whatever" | tee /dev/tty
      +echo "whatever" | tee /dev/tty || true
    This commit deals with messages that are printed only to /dev/tty, e.g.:
      -echo Finished building lmi. >/dev/tty
      +tty -s && echo Finished building lmi. >/dev/tty
    Although the same '|| true' technique would work here as well, testing
    'tty -s' seems slightly less inelegant, as it does avoid messages like:
      /dev/tty: No such device or address
    which are tolerated in the 'tee /dev/tty' case where suppressing them is
    too much bother.
---
 gwc/install_posix.sh | 2 +-
 gwc/speed_test.sh    | 2 +-
 gwc/toms_vs_brent.sh | 8 ++++----
 gwc/unit_test.sh     | 2 +-
 install_msw.sh       | 4 ++--
 nychthemeral_test.sh | 2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/gwc/install_posix.sh b/gwc/install_posix.sh
index 29b0cdf6..12139905 100755
--- a/gwc/install_posix.sh
+++ b/gwc/install_posix.sh
@@ -246,4 +246,4 @@ seconds=$(($(date '+%s' -d "$stamp1") - $(date '+%s' -d 
"$stamp0")))
 elapsed=$(date -u -d @"$seconds" +'%H:%M:%S')
 echo "Elapsed: $elapsed"
 
-echo Finished building lmi. >/dev/tty
+tty -s && echo Finished building lmi. >/dev/tty
diff --git a/gwc/speed_test.sh b/gwc/speed_test.sh
index fd40e75f..ab771784 100755
--- a/gwc/speed_test.sh
+++ b/gwc/speed_test.sh
@@ -24,7 +24,7 @@ case "$toolchain" in
         ;;
 esac
 {
-printf 'toolchain = "%s"\n' "$toolchain" > /dev/tty
+tty -s && printf 'toolchain = "%s"\n' "$toolchain" > /dev/tty
 # shellcheck disable=SC2154
   make "$coefficiency" cli_timing > /dev/null
 }
diff --git a/gwc/toms_vs_brent.sh b/gwc/toms_vs_brent.sh
index 77f55231..003971f7 100755
--- a/gwc/toms_vs_brent.sh
+++ b/gwc/toms_vs_brent.sh
@@ -6,9 +6,9 @@
 # then extract the results of the tests in the TOMS 748 paper and
 # save them to distinct files.
 
-printf 'i686-w64-mingw32 no longer supported; do' > /dev/tty
-printf '  "git switch --detach 72547df8069cfb"'   > /dev/tty
-printf 'if you require i686+x87 timings.'         > /dev/tty
+tty -s && printf 'i686-w64-mingw32 no longer supported; do' > /dev/tty
+tty -s && printf '  "git switch --detach 72547df8069cfb"'   > /dev/tty
+tty -s && printf 'if you require i686+x87 timings.'         > /dev/tty
 
 # 'triplets' really is used, but in a zsh-specific way
 # shellcheck disable=SC2034
@@ -20,7 +20,7 @@ for LMI_TRIPLET in ${=triplets} ;
 do
 log_dir=$(dirname "$(readlink --canonicalize "$0")")
 {
-printf 'LMI_TRIPLET = "%s"\n' "$LMI_TRIPLET" > /dev/tty
+tty -s && printf 'LMI_TRIPLET = "%s"\n' "$LMI_TRIPLET" > /dev/tty
 
 make clean
 # shellcheck disable=SC2039,SC2154,SC3001
diff --git a/gwc/unit_test.sh b/gwc/unit_test.sh
index 632d1dfb..a49e8dc2 100755
--- a/gwc/unit_test.sh
+++ b/gwc/unit_test.sh
@@ -31,7 +31,7 @@ exec_prefix="$prefix/${LMI_COMPILER}_${LMI_TRIPLET}"
 log_dir="$exec_prefix"/logs
 mkdir --parents "$log_dir"
 {
-printf 'toolchain: %s\n' "${LMI_COMPILER}_${LMI_TRIPLET}" > /dev/tty
+tty -s && printf 'toolchain: %s\n' "${LMI_COMPILER}_${LMI_TRIPLET}" > /dev/tty
 # shellcheck disable=SC2039,SC2154,SC3001
   make "$coefficiency" --output-sync=recurse unit_tests 2>&1 \
     | tee \
diff --git a/install_msw.sh b/install_msw.sh
index 0e9298be..567373a7 100755
--- a/install_msw.sh
+++ b/install_msw.sh
@@ -249,7 +249,7 @@ then
     restore_cache_mount=$(mount --mount-entries | grep '/srv/cache_for_lmi ')
     [ -z "$restore_cache_mount" ] \
       || printf '%s\n' "$restore_cache_mount" | grep --silent 
'C:/srv/cache_for_lmi' \
-      || printf 'Replacing former cache mount:\n  %s\n' "$restore_cache_mount" 
>/dev/tty
+      || printf 'Replacing former cache mount:\n  %s\n' "$restore_cache_mount"
     mount --force "C:/srv/cache_for_lmi" "/srv/cache_for_lmi"
 fi
 
@@ -439,4 +439,4 @@ seconds=$(($(date '+%s' -d "$stamp1") - $(date '+%s' -d 
"$stamp0")))
 elapsed=$(date -u -d @"$seconds" +'%H:%M:%S')
 echo "Elapsed: $elapsed"
 
-echo Finished building lmi. >/dev/tty
+tty -s && echo Finished building lmi. >/dev/tty
diff --git a/nychthemeral_test.sh b/nychthemeral_test.sh
index e9804e10..fbfae703 100755
--- a/nychthemeral_test.sh
+++ b/nychthemeral_test.sh
@@ -326,7 +326,7 @@ exec_prefix="$prefix/${LMI_COMPILER}_${LMI_TRIPLET}"
 log_dir="$exec_prefix"/logs
 mkdir --parents "$log_dir"
 {
-printf 'toolchain: %s\n' "${LMI_COMPILER}_${LMI_TRIPLET}" > /dev/tty
+tty -s && printf 'toolchain: %s\n' "${LMI_COMPILER}_${LMI_TRIPLET}" > /dev/tty
 
 # Cannot recursively check script on path determined at runtime, so
 # a directive like 'source="$srcdir"' doesn't work.



reply via email to

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