Skip to content

env: trace environment changes with -v - #14263

Open
wtcpython wants to merge 1 commit into
uutils:mainfrom
wtcpython:env-verbose-trace
Open

wtcpython wants to merge 1 commit into
uutils:mainfrom
wtcpython:env-verbose-trace

Conversation

@wtcpython

Copy link
Copy Markdown
Contributor

Fixes #14171.

GNU traces each environment change in verbose mode, and -vv is just -v
repeated. We printed nothing for -v and dumped the input args for -vv.

Print the same trace lines as GNU (cleaning environ, setenv, unset,
chdir) and drop the argument dump. Add tests for the traced output and for
-vv matching -v.

@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: 152.18 MB (+1004 KB, +0.65%)

Significant per-binary changes:
  comm     1.12 MB ->    2.33 MB  (+1.21 MB, +107.29%)

@github-actions

github-actions Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/id/setgid is no longer failing!

Comment thread src/uu/env/src/env.rs Outdated
));
}
// GNU traces only the unsets that remove something
if opts.debug && env::var_os(name).is_some() {

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.

GNU prints unset: unconditionally, even for a variable that isn't set or an invalid name

Comment thread tests/by-util/test_env.rs
assert_eq!(result.stderr_str(), "unset: ENV_VERBOSE_UNSET_ME\n");

// unsetting a variable that does not exist is not traced
let result = new_ucmd!()

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.

GNU does trace it. Should expect unset: ENV_VERBOSE_NOT_SET

Comment thread src/uu/env/src/env.rs
);
continue;
}
if opts.debug {

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.

to_string_lossy() mangles non-UTF-8 args - GNU passes the raw bytes through. Write the OsStr bytes to stderr instead. Same at line 1065.

@wtcpython
wtcpython force-pushed the env-verbose-trace branch 2 times, most recently from 450d95a to 85d29c9 Compare August 31, 2026 01:45
Copilot AI lite review requested due to automatic review settings September 7, 2026 03: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.

@wtcpython

Copy link
Copy Markdown
Contributor Author

@sylvestre ready

Copilot AI review requested due to automatic review settings September 14, 2026 06:38

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 17, 2026 13:35

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.

@codspeed

codspeed Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 4.97%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 390 untouched benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation three_39_bit_primes 684.4 ms 779.3 ms -12.18%
❌ Simulation five_38_bit_primes 1.7 s 1.9 s -6.42%
⚡ Simulation thirteen_39_bit_primes 9.3 s 8.9 s +4.42%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing wtcpython:env-verbose-trace (18dea1f) with main (5b2e6e0)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Copilot AI review requested due to automatic review settings September 19, 2026 00:36

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: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 24, 2026 07: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.

Copilot AI review requested due to automatic review settings September 25, 2026 00:55

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 27, 2026 00: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.

Copilot AI review requested due to automatic review settings September 29, 2026 06:09

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 September 30, 2026 03:20

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 1, 2026 11: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.

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

Review effort: Lite
Findings: 2 Medium severity

Open (2)

Comment thread src/uu/env/src/env.rs
Comment on lines 997 to 1007
fn apply_unset_env_vars(opts: &Options<'_>) -> Result<(), Box<dyn UError>> {
for name in &opts.unsets {
if opts.debug {
let mut error = stderr().lock();
let _ = error.write_all(b"unset: ");
let _ = error.write_all_os(name);
let _ = error.write_all(b"\n");
}
let native_name = NativeStr::new(name);
if name.is_empty()
|| native_name.contains('\0').unwrap()
Comment thread src/uu/env/src/env.rs
Comment on lines +1032 to 1037
if opts.debug {
let mut error = stderr().lock();
let _ = writeln!(error, "chdir: {}", d.quote());
}
match env::set_current_dir(d) {
Ok(()) => d,
Copilot AI lite review requested due to automatic review settings October 2, 2026 10:41

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.

This branch has not been deployed

No deployments
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.

env: -v / -vv don't trace environment changes

3 participants