Skip to content

printenv: Honor QUOTING_STYLE environment variable - #14857

Open
RenjiSann wants to merge 3 commits into
uutils:mainfrom
RenjiSann:printenv-quoting-style
Open

RenjiSann wants to merge 3 commits into
uutils:mainfrom
RenjiSann:printenv-quoting-style

Conversation

@RenjiSann

@RenjiSann RenjiSann commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Depends on #14856

Make printenv check for QUOTING_STYLE and adapt its output accordingly

Should make tests/misc/printenv.sh pass

DIFF

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/env/printenv is no longer failing!

@codspeed

codspeed Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 9.99%

1 warning, 1 note

⚠️ 119 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
✅ 400 untouched benchmarks
⏩ 70 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation ls_recursive_wide_tree[(10000, 1000)] 73.5 ms 66.8 ms +9.99%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing RenjiSann:printenv-quoting-style (59afbaf) with main (8e267ce)2

Open in CodSpeed

Footnotes

  1. 70 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. ↩

  2. No successful run was found on main (19f6602) during the generation of this report, so 8e267ce was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch 2 times, most recently from 738e4bd to 4e9570c Compare September 25, 2026 11:35
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch 3 times, most recently from 7808763 to 1b977c0 Compare September 28, 2026 13:34
@cakebaker

Copy link
Copy Markdown
Contributor

@RenjiSann the dependency has been merged in the meantime :)

@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch from 1b977c0 to 79d38b1 Compare October 5, 2026 12:09
@RenjiSann

Copy link
Copy Markdown
Collaborator Author

@RenjiSann the dependency has been merged in the meantime :)

Yep, but the GNU test isn't fixed just yet, I'll investigate

@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch from 79d38b1 to 8ca4cfa Compare October 13, 2026 09:45
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch 3 times, most recently from 2ff7ce1 to 78e92ed Compare October 21, 2026 15:58
@RenjiSann
RenjiSann marked this pull request as ready for review October 21, 2026 17:28
@xtqqczze

This comment was marked as outdated.

@RenjiSann
RenjiSann requested a review from cakebaker October 22, 2026 08:31
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch from 78e92ed to b48a514 Compare October 23, 2026 16:44
@RenjiSann
RenjiSann requested a review from sylvestre October 25, 2026 23:22
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch 4 times, most recently from 3475f9c to a1f396e Compare October 29, 2026 16:35
@RenjiSann

Copy link
Copy Markdown
Collaborator Author

@cakebaker should be ready to review ^^

Comment thread src/uu/env/src/env.rs Resolved
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch 2 times, most recently from a066490 to f056eda Compare October 30, 2026 10:57
Comment thread Cargo.lock Resolved
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch from f056eda to 870fb8b Compare October 30, 2026 13:52
Comment thread tests/by-util/test_printenv.rs Resolved
Comment thread tests/by-util/test_printenv.rs Resolved
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch from 870fb8b to 1e9c62a Compare October 30, 2026 15:58
Comment thread src/uu/env/src/env.rs Outdated
// no program provided, so just dump all env vars to stdout
print_all_env_vars(opts.line_ending)?;
// `encoding` is irrelevant when `quoting_style` is None
print_all_env_vars(opts.line_ending, None, UEncoding::Ascii)?;

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.

env now needs the quoting-style feature just to pass None here
could we keep a plain print_all_env_vars and not gate it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Duplicated the print_all_env_vars to a "quoting-style"-gated print_all_env_vars_quoted variant, that takes the quoting_style and encoding arguments.

printenv-usage = printenv [OPTION]... [VARIABLE]...

printenv-help-null = end each output line with 0 byte rather than newline
printenv-help-quoting-style = set quoting style

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.

could you please list the accepted values in the help, like ls does?


let maybe_quoting_style = matches
.get_one::<String>(OPT_QUOTING_STYLE)
.and_then(QuotingStyle::parse)

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.

an invalid --quoting-style=foo is silently ignored here, could we reject it with a value_parser like ls does?
please add a test for it too

.and_then(QuotingStyle::parse)
.or_else(|| {
std::io::stdout()
.is_terminal() // quoting style from env var is only used in TTY

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.

why only on a tty? stat and ls use QUOTING_STYLE whatever stdout is

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Only following GNU behavior here

Comment thread src/uu/printenv/src/printenv.rs Resolved
pub fn print_all_env_vars<T: fmt::Display>(line_ending: T) -> io::Result<()> {
#[cfg(feature = "quoting-style")]
pub fn print_all_env_vars<T: fmt::Display>(
line_ending: T,

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.

why gate the whole function behind quoting-style? only the escaping needs it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As mentioned above, created a specific print_all_env_vars_quoted

Comment thread tests/by-util/test_printenv.rs Resolved
Comment thread tests/by-util/test_printenv.rs Resolved
@RenjiSann
RenjiSann marked this pull request as draft November 2, 2026 21:47
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch 4 times, most recently from 1291986 to 9907277 Compare November 2, 2026 22:25
@RenjiSann
RenjiSann force-pushed the printenv-quoting-style branch from 9907277 to 7369440 Compare November 2, 2026 22:45
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Binary size comparison:

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

Total size of compared binaries: 155.13 MB (+60 KB, +0.04%)

Significant per-binary changes:
  printenv     1.09 MB ->    1.15 MB  (+60 KB, +5.36%)

@RenjiSann
RenjiSann marked this pull request as ready for review November 2, 2026 23:18
@RenjiSann RenjiSann closed this Nov 2, 2026
@RenjiSann

Copy link
Copy Markdown
Collaborator Author

test_pr::test_merge_non_utf8_input_filename fails on main, unrelated with this patch

@RenjiSann RenjiSann reopened this Nov 2, 2026

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.

4 participants