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

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
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.

Collin
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.