summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-08-09 08:22:10 +0100
committerSam James <sam@gentoo.org>2024-08-11 11:11:01 +0100
commit52d8b440df4e68c9c3dfdea7f3142b1641f2b08e (patch)
treefa4c64f5a1cfc188b34668d5f4a8c5223f208024 /functions.sh
parentHandle integer overflow as a special case in _should_throttle() (diff)
downloadgentoo-functions-52d8b440df4e68c9c3dfdea7f3142b1641f2b08e.tar.gz
gentoo-functions-52d8b440df4e68c9c3dfdea7f3142b1641f2b08e.tar.bz2
gentoo-functions-52d8b440df4e68c9c3dfdea7f3142b1641f2b08e.zip
Render _update_time() a no-op for the yash shell
When integer overflow occurs in a non-interactive yash shell, it prints "yash: arithmetic: overflow" as a diagnostic message before proceeding to exit. That makes it extremely difficult for the arithmetic in the _should_throttle() function to be implemented safely for it. For now, ensure that _update_time() does nothing for yash but return a non-zero status code. In turn, this disables the rate limiting feature for yash. Additionally, refrain from running test_update_time() and test_should_throttle() for yash in test-functions. The former would only amount to a waste of time and the latter would be guaranteed to fail. For the record, my testing was performed with yash 2.56.1. Signed-off-by: Kerin Millar <kfm@plushkava.net> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'functions.sh')
-rw-r--r--functions.sh3
1 files changed, 2 insertions, 1 deletions
diff --git a/functions.sh b/functions.sh
index e7ef6fe..641deb6 100644
--- a/functions.sh
+++ b/functions.sh
@@ -846,7 +846,8 @@ _update_time()
fi
genfun_time=$(( s * 100 + cs ))
}
- elif [ -f /proc/uptime ]; then
+ elif [ -f /proc/uptime ] && [ ! "${YASH_VERSION}" ]; then
+ # Yash is blacklisted because it dies upon integer overflow.
_update_time()
{
local cs s