Skip to content

unexpand: accept a blank as a tab-list separator like GNU - #14057

Open
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:unexpand-space-tab-separator
Open

unexpand: accept a blank as a tab-list separator like GNU#14057
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:unexpand-space-tab-separator

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor

GNU unexpand accepts both a comma and a blank between tab stops in -t/--tabs, so unexpand -t '2 3' behaves like unexpand -t '2,3'. uutils only splits on a comma, so the space form is rejected:

$ printf '  a   b\n' | unexpand -t '2 3' -a
unexpand: tab size contains invalid character(s): ' 3'

uutils' own expand already accepts both separators via an is_space_or_comma helper; only unexpand was inconsistent. This splits the tab list on a space or a comma too, mirroring expand. Verified byte for byte against GNU unexpand in the C locale for '2 3', ' 2 3', '2 3', '2, 3' and '1 4 7'; invalid values like -t x still error as before.

@codspeed-hq

codspeed-hq Bot commented Aug 21, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.84%

⚠️ 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
✅ 356 untouched benchmarks
⏩ 50 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_wide_tree[(5000, 500)] 20.5 ms 19.8 ms +3.84%

Tip

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


Comparing AlejandroCoronadoN:unexpand-space-tab-separator (7c49a86) with main (ec8adb5)

Open in CodSpeed

Footnotes

  1. 50 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.

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/cp/sparse-to-pipe. tests/cp/sparse-to-pipe is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

Comment thread src/uu/unexpand/src/unexpand.rs Outdated
}

/// Decide whether the character is either a space or a comma.
fn is_space_or_comma(c: char) -> bool {

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.

Not a useful function. Please remove it and write code directly.

@AlejandroCoronadoN
AlejandroCoronadoN force-pushed the unexpand-space-tab-separator branch from 2a16155 to 80248df Compare August 21, 2026 09:41
@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor Author

Good point, removed the helper and inlined it as s.split([' ', ',']). Thanks for the review!

@sylvestre

Copy link
Copy Markdown
Contributor

GNU splits on blank, so a literal TAB is a valid separator too - s.split([' ', '\t', ',']). expand's is_space_or_comma has the same gap; worth fixing both here.

@AlejandroCoronadoN
AlejandroCoronadoN force-pushed the unexpand-space-tab-separator branch from 80248df to 7c49a86 Compare August 21, 2026 21:40
@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor Author

Good catch, added the tab so the split is now s.split([' ', '\t', ',']). Verified against GNU unexpand with a tab separator. Thanks!

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.

3 participants