ninja-build/ninja

Environment variable with a hyphen is dropped in ubuntu

Open

#2.288 aberto em 20 de abr. de 2023

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)C++ (1.544 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (10.194 stars)
Métricas de merge de PR
 (Mesclagem média 39d 3h) (10 fundiu PRs em 30d)

Description

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

Guia do colaborador