bug#79714: env: always adds __CF_USER_TEXT_ENCODING var on macOS since v9.8

Bruno Haible via GNU coreutils Bug Reports <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Organization GNU
Message-ID <1976904.Bm8zEkEi59@nimes>
Andrew Marshall wrote:
> perhaps it’s worth documenting or making it an invalid config on Darwin.

We could document that users should not use environment variables
that start with "__", because these environment variables can be
set by the OS and can influence the behaviour of the OS. Proposed
patch is attached.

Once that is documented, I don't think anything is wrong with
CoreFoundation setting or use any __FOOBAR environment variable(s).

Bruno
0001-env-document-role-of-environment-variables-that-star.patch (text/x-patch, 1.1 KB)
From 3291e071140b01129c0e5b57967405434b35b325 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sun, 2 Nov 2025 10:21:15 +0100
Subject: [PATCH] env: document role of environment variables that start with
 __

* doc/coreutils.texi (env invocation): Document role of environment
variables that start with __.
---
 doc/coreutils.texi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 13f9f9a46..061228b90 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -18135,6 +18135,11 @@ However, it is wise to limit yourself to names that
 consist solely of underscores, digits, and ASCII letters,
 and that begin with a non-digit, as applications like the shell do not
 work well with other names.
+Also, you should avoid environment variables with names that start
+with two underscores,
+@c So far, this applies only to macOS and __CF_USER_TEXT_ENCODING.
+because such environment variables can be set by the operating system
+or influence the behavior of the operating system.
 
 @vindex PATH
 The first operand that does not contain the character @samp{=}
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.