Repository navigation
env: support --env0-from - #14609
env: support --env0-from#14609
Conversation
d9c06ce to
1f30a20
Compare
|
GNU testsuite comparison: |
1f30a20 to
02d6bdb
Compare
9251dbe to
95b3b13
Compare
95b3b13 to
6f59050
Compare
6f59050 to
6632dee
Compare
6632dee to
c05e0c4
Compare
c05e0c4 to
d7b7c92
Compare
d7b7c92 to
5aa10c7
Compare
5aa10c7 to
e9c0b1d
Compare
dfa874f to
2f363dc
Compare
2f363dc to
b881279
Compare
b881279 to
5b0d6d3
Compare
5b0d6d3 to
120e7c0
Compare
There was a problem hiding this comment.
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.
120e7c0 to
3b2464b
Compare
There was a problem hiding this comment.
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.
3b2464b to
fad7542
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
9 open issues
fileis an&OsStr, and comparing it directly to a&str(\"-\") is not guaranteed to compile… · New This loop dereferencesptrwithout checking whetherptritself is null first. In… · New Temporarily overwriting the globalenvironpointer is not thread-safe (it can race with other… This loop dereferencesptr(*ptr) without first checking whetherptritself is null. If… Temporarily mutating the globalenvironpointer is not thread-safe; any concurrent environment… · New This test hard-codes an absolute Unix-style path (/nonexistent_file_12345), which can be… · New On non-Unix,--env0-fromclears the environment and then silently skips entries that are opaque…entry_keyreturnsSome(&[] )for entries that start with=(i.e., an empty name). Downstream… Usingfilter_map(... .ok())silently drops entries ifCString::newfails. Even if failures are… · New
Review effort: Lite
| 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) | ||
| }; |
| 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); | ||
| } |
| let orig = envp_ptrs.as_mut().map(|ptrs| unsafe { | ||
| let p = *environ(); | ||
| *environ() = ptrs.as_mut_ptr(); | ||
| p | ||
| }); |
| new_ucmd!() | ||
| .arg("--env0-from=/nonexistent_file_12345") | ||
| .fails_with_code(125) | ||
| .stderr_contains("cannot read '/nonexistent_file_12345'"); |
| let env_cstrings = custom_env.map(|entries| { | ||
| entries | ||
| .iter() | ||
| .filter_map(|e| CString::new(e.clone()).ok()) | ||
| .collect::<Vec<_>>() | ||
| }); |
fad7542 to
1044fa0
Compare
|
sorry but it needs to be rebased, and clippy is sad :), and a bunch of jobs are failing |
1044fa0 to
0a1d5da
Compare
0a1d5da to
8f40c09
Compare
|
Binary size comparison: |



Closes #14602.
Support
--env0-from=FILEto read environment variables from a NUL-delimited file, matching GNUenv9.12.Should make test tests/env/env0-from.sh pass