commit 67c1b3dc0ac51c35c90bf4d0979e67a364375831
Author: Scott Kostyshak <skost...@lyx.org>
Date:   Tue Mar 18 12:21:01 2025 +0100

    lyx-tester switches: delay calculations
    
    This file is typically sourced by the user into the bash sessions,
    but created these contsants takes about half a second, which the
    user does not want when not calling the switches.
    
    Instead, the calculations are still centralized but now implemented
    as functions so that the calculations are done only when used.
---
 development/lyx-tester/switches | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/development/lyx-tester/switches b/development/lyx-tester/switches
index b89042d545..44c90fabc4 100644
--- a/development/lyx-tester/switches
+++ b/development/lyx-tester/switches
@@ -7,22 +7,35 @@
 # message)
 
 
+
 # where to archive the TL version
 _polyglossia_dev_d="/home/$(logname)/polyglossia"
 
-# location of TL version
-_polyglossia_tl_d="$(/opt/texbin/kpsewhich polyglossia.sty | xargs dirname )"
-
-# e.g., "TL25_2025-03-16"
-_tl_dirname="$( basename "$( dirname "$( kpsewhich -var-value TEXMFDIST )")")"
-# this is the dir outside of the TL tree where we store the TL polyglossia
-# dir when we replace it with a symlink to the dev dir.
-_polyglossia_tl_bu_d="/home/$(logname)/polyglossia_tl/${_tl_dirname}"
 
 _tl_stable_bu_d="/home/$(logname)/tl-stable-binaries"
 _tl_texbin_d="/opt/texbin/"
 
 
+# these functions are basically used as constants, but implemented as functions
+# to avoid expensive calculation every time a bash session is started.
+#
+function _poly-tl-d ()
+{
+  # location of TL version
+  /opt/texbin/kpsewhich polyglossia.sty | xargs dirname
+}
+#
+#
+function _poly-tl-bu-d ()
+{
+  # e.g., "TL25_2025-03-16"
+  _tl_dirname="$( basename "$( dirname "$( kpsewhich -var-value TEXMFDIST 
)")")"
+  # this is the dir outside of the TL tree where we store the TL polyglossia
+  # dir when we replace it with a symlink to the dev dir.
+  echo "/home/$(logname)/polyglossia_tl/${_tl_dirname}"
+}
+
+
 function switch-polyglossia-to-dev ()
 {
 
@@ -36,6 +49,9 @@ function switch-polyglossia-to-dev ()
   #       repo are different so we are notified when we need to update them.
 
 
+  _polyglossia_tl_d="$(_poly-tl-d)"
+  _polyglossia_tl_bu_d="$( _poly-tl-bu-d )"
+
   # check whether link or not link to see whether current is tl or dev.
   if [ -L "${_polyglossia_tl_d}" ]; then
     echo "Link exists, so you are already using polyglossia-dev."
@@ -60,6 +76,9 @@ function switch-polyglossia-to-dev ()
 
 function switch-polyglossia-to-stable ()
 {
+  _polyglossia_tl_d="$(_poly-tl-d)"
+  _polyglossia_tl_bu_d="$( _poly-tl-bu-d )"
+
   if [ -L "${_polyglossia_tl_d}" ]; then
     sudo rm "${_polyglossia_tl_d}"
     sudo mv "${_polyglossia_tl_bu_d}" "${_polyglossia_tl_d}"
@@ -77,6 +96,8 @@ function switch-polyglossia-to-stable ()
 # in a script that updates the TeX Live installation.
 function polyglossia-is-stable ()
 {
+  _polyglossia_tl_d="$(_poly-tl-d)"
+
   if [ -L "${_polyglossia_tl_d}" ]; then
     # 0 = no, not stable
     echo "0"
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to