commit: e9e8c66c681b980668a8e9225bf8ec19135b9acc
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Aug 11 18:37:44 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 17 16:16:36 2024 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=e9e8c66c
Ensure that LC_ALL is exported in srandom(); be safer for macOS
The slowest implementation of srandom() runs od(1) and awk(1) within a
command substitution. There, both LC_ALL and LC_CTYPE are overridden but
they should also be exported.
For now, export LC_ALL=C exclusively, even though it overrides
LC_MESSAGES, potentially affecting the user's preferred language for
diagnostics. The reason for choosing this course of action is as
follows.
$ uname
Darwin
$ echo "$BASH_VERSION"
5.2.26(1)-release
$ f() { nonexistent; }; $ ( export LC_ALL=; f )
objc[29971]: +[__SwiftNativeNSStringBase initialize] may have been in
progress in another thread when fork() was called.
objc[29971]: +[__SwiftNativeNSStringBase initialize] may have been in
progress in another thread when fork() was called. We cannot safely call
it or ignore it in the fork() child process. Crashing instead. Set a
breakpoint on objc_initializeAfterForkError to debug.
A fix for this is present in the devel branch:
- https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=b3d8c8a
See, also:
- https://trac.macports.org/ticket/68638
- https://lists.gnu.org/archive/html/bug-bash/2024-05/msg00088.html
Of course, the fix hasn't been backported to an actual release. As such,
I would prefer to play it safe for the time being.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
functions.sh | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/functions.sh b/functions.sh
index 8b7896f..406fe7f 100644
--- a/functions.sh
+++ b/functions.sh
@@ -590,8 +590,7 @@ srandom()
local hex
hex=$(
- LC_ALL=
- LC_CTYPE=C
+ export LC_ALL=C
od -vAn -N256 -tx1 /dev/urandom | awk '
{
gsub(/[[:space:]]/, "")