Skip to content

env: support --env0-from - #14609

Merged
sylvestre merged 1 commit into
uutils:mainfrom
wtcpython:env-env0-from
Nov 17, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
wtcpython:env-env0-from

Conversation

@wtcpython

@wtcpython wtcpython commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14602.

Support --env0-from=FILE to read environment variables from a NUL-delimited file, matching GNU env 9.12.

Should make test tests/env/env0-from.sh pass

@wtcpython
wtcpython marked this pull request as ready for review September 17, 2026 01:40
Copilot AI lite review requested due to automatic review settings September 17, 2026 01:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/env/env is no longer failing!
Congrats! The gnu test tests/env/env0-from is no longer failing!
Congrats! The gnu test tests/misc/usage_vs_getopt is no longer failing!

@oech3

oech3 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings September 17, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 19, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 20, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 21, 2026 00:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 21, 2026 06:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 21, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 21, 2026 07:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 23, 2026 00:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 4, 2026 01:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 9, 2026 00:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 10, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI lite review requested due to automatic review settings October 15, 2026 08:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@wtcpython
wtcpython requested a review from cakebaker October 15, 2026 08:06
Copilot AI lite review requested due to automatic review settings October 21, 2026 01:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Copilot AI lite review requested due to automatic review settings November 3, 2026 08:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/uu/env/src/env.rs
Comment on lines +348 to +354
fn read_env0_file(file: &OsStr) -> UResult<Vec<u8>> {
let res = if file == "-" {
let mut buf = Vec::new();
io::stdin().read_to_end(&mut buf).map(|_| buf)
} else {
std::fs::read(file)
};
Comment thread src/uu/env/src/env.rs
Comment on lines +1054 to +1063
let mut ptr = *environ();
while !(*ptr).is_null() {
let cstr = std::ffi::CStr::from_ptr(*ptr);
writer.write_all(cstr.to_bytes())?;
match opts.line_ending {
LineEnding::Nul => writer.write_all(b"\0")?,
LineEnding::Newline => writer.write_all(b"\n")?,
}
ptr = ptr.add(1);
}
Comment thread src/uu/env/src/env.rs
Comment on lines +1168 to +1172
let orig = envp_ptrs.as_mut().map(|ptrs| unsafe {
let p = *environ();
*environ() = ptrs.as_mut_ptr();
p
});
Comment thread tests/by-util/test_env.rs
Comment on lines +2429 to +2432
new_ucmd!()
.arg("--env0-from=/nonexistent_file_12345")
.fails_with_code(125)
.stderr_contains("cannot read '/nonexistent_file_12345'");
Comment thread src/uu/env/src/env.rs
Comment on lines +1155 to +1160
let env_cstrings = custom_env.map(|entries| {
entries
.iter()
.filter_map(|e| CString::new(e.clone()).ok())
.collect::<Vec<_>>()
});
@sylvestre

Copy link
Copy Markdown
Contributor

sorry but it needs to be rebased, and clippy is sad :), and a bunch of jobs are failing

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.49 MB (+104 KB, +0.07%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

@sylvestre
sylvestre merged commit 0ac92f4 into uutils:main Nov 17, 2026
102 of 109 checks passed
@wtcpython
wtcpython deleted the env-env0-from branch November 17, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants