ninja-build/ninja

Environment variable with a hyphen is dropped in ubuntu

Open

#2.288 geöffnet am 20. Apr. 2023

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (1.544 Forks)batch import
bughelp wanted

Repository-Metriken

Stars
 (10.194 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 39T 3h) (10 gemergte PRs in 30 T)

Beschreibung

Feel free to close this as invalid, the bug is likely not in ninja, as it looks like ninja simply does a posix_spawn to launch a process without modifying the environment. Though interestingly I could not reproduce the issue without ninja (tried my own wrapper that does posix_spawn etc), so opening it here as someone else might have experienced the same issue.

populate buid.ninja with

rule environ
    command = env

build env.txt: environ

Run ninja with command:

env - FOO_bar=1 FOO_baz-baz=2 ninja

Expected output from env should include both FOO_bar and FOO_baz-baz variables, but on some systems you will only see the variable without hyphen in the name, those with hyphen are dropped somewhere.

So far I've tested: Ubuntu: Buggy Linux Mint: Buggy Fedora: Works Fine Arch: works Fine

I've also debugged by making ninja printing environ just before doing posix_spawn and I can see the variable FOO_baz-baz there, it just isn't visible in the launched process.

My guess is that ubuntu glibc does something wrong somewhere, but I couldn't find it

Contributor Guide