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

Pádraig Brady <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
On 29/10/2025 03:51, Collin Funk wrote:
> Collin Funk <[email protected]> writes:
> 
>> My intuition is that calling the Core Foundation locale functions will
>> cause that environment variable to be set along with creating that file.
>>
>> Can you share the ./configure options you used? Or did you download
>> Coreutils through Homebrew? That would help lead me in the right
>> direction, I think.
> 
> Actually the environment variable is set in any program that is linked
> against Core Foundation. Regardless of whether you call functions from
> it or not. See the following test program:
> 
>      $ cat main.c
>      #include <stdio.h>
>      #include <stdlib.h>
>      int
>      main (void)
>      {
>        char *p = getenv ("__CF_USER_TEXT_ENCODING");
>        printf ("%s\n", p ? p : "(null)");
>        return EXIT_SUCCESS;
>      }
>      $ ./a.out
>      (null)
>      $ cc main.c -Wl,-framework -Wl,CoreFoundation
>      $ ./a.out
>      0xF23D:0:0
> 
> I believe Core Foundation is needed for our setlocale substitute on
> MacOS.

Oh interesting.
That would be a reason to not link env(1) against it.
In fact only 6 commands require the localename-unsafe dependency:  date, du through show-date() (fprintftime), and
   ls, pr, stat, uptime through strftime().
So I'll adjust things to only link those against CoreFoundation.

cheers,
Padraig
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.