commit: 52d8b440df4e68c9c3dfdea7f3142b1641f2b08e
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Aug 9 07:22:10 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 11 10:11:01 2024 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=52d8b440
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 <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
functions.sh | 3 ++-
test-functions | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
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
diff --git a/test-functions b/test-functions
index 34ffc41..c96ac48 100755
--- a/test-functions
+++ b/test-functions
@@ -1024,6 +1024,12 @@ test_deref() {
test_update_time() {
local locale
+ # The yash shell dies upon integer overflow and _update_time() ends up
+ # being deactivated for it. Hence, there is no reason to run this test.
+ if [ "${YASH_VERSION}" ]; then
+ return
+ fi
+
set -- \
de_BE de_DE es_ES fr_BE fr_CA fr_FR it_IT nl_BE nl_NL pl_PL \
pt_BR pt_PT ru_RU sv_SE
@@ -1072,6 +1078,12 @@ test_update_time() {
test_should_throttle() {
local bits max_int
+ # The yash shell dies upon integer overflow and _update_time() ends up
+ # being deactivated for it. Hence, there is no reason to run this test.
+ if [ "${YASH_VERSION}" ]; then
+ return
+ fi
+
genfun_time=
bits=30
while [ "${bits}" -lt 128 ]; do