Skip to content

dd: fix conv=block/unblock conflict handling - #14773

Merged
sylvestre merged 1 commit into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-dd-conv-conflicts
Oct 13, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-dd-conv-conflicts

Conversation

@ChihweiLHBird

@ChihweiLHBird ChihweiLHBird commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

conv=block and conv=unblock convert between newline-terminated lines and fixed-size records; cbs=N sets the record size. The ascii conversion implies unblock, and ebcdic and ibm imply block.

Three things were off in how uutils handled the block/unblock pair:

  1. Implied directions were not considered. conv=ascii,block cbs=1 asks for both unblock (via ascii) and block, but uutils accepted it silently. GNU rejects it as a block/unblock conflict.
  2. It was checked last. GNU checks conflicts in a fixed order: ascii/ebcdic/ibm, then block/unblock, then lcase/ucase, then excl/nocreat. uutils checked block/unblock after the others, so conv=block,unblock,lcase,ucase cbs=1 reported the lcase/ucase conflict instead of the block/unblock one.
  3. Missing cbs was an error. GNU ignores block and unblock when cbs is not given; uutils refused with its own "specified without cbs=N" message. POSIX leaves this case unspecified, so this part is a compatibility choice rather than a bug fix.

This PR moves the block/unblock check to its place in that order, includes the implied directions, and only performs it when cbs is given.

Example

$ dd conv=ascii,block cbs=1 if=/dev/null

Before: silent, exit 0. After, same as GNU: dd: cannot combine block and unblock, exit 1.

$ dd conv=block,unblock,lcase,ucase cbs=1 if=/dev/null

Before: dd: cannot combine lcase and ucase. After, same as GNU: dd: cannot combine block and unblock.

$ printf 'ab\n' | dd conv=block status=none

Before: dd: conv=block or conv=unblock specified without cbs=N, exit 1. After, same as GNU: prints ab, exit 0.

@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-dd-conv-conflicts branch from 8062aff to 8fbfb8b Compare September 21, 2026 08:18
@ChihweiLHBird
ChihweiLHBird marked this pull request as ready for review September 21, 2026 08:19
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-dd-conv-conflicts branch from 8fbfb8b to 6def12c Compare September 21, 2026 08:30
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)

@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-dd-conv-conflicts branch 4 times, most recently from 272fc15 to d794ae3 Compare September 27, 2026 19:31
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-dd-conv-conflicts branch from d794ae3 to 92bedb3 Compare September 28, 2026 19:28
Copilot AI balanced review requested due to automatic review settings October 9, 2026 00:19
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-dd-conv-conflicts branch from 92bedb3 to dbfc768 Compare October 9, 2026 00:19

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.

🟢 Approval recommended

The parser changes are coherent, correctly ordered, and covered by targeted tests.

0 open findings

What changed in this PR

Updates dd argument validation to match GNU-compatible block/unblock behavior.

Changes:

  • Detects implied and explicit conversion conflicts in the correct order.
  • Ignores block/unblock when cbs is absent.
  • Adds regression coverage and removes the obsolete error translation.
File Description
src/​uu/​dd/​src/​parseargs.rs Revises conversion validation and mode selection.
src/​uu/​dd/​src/​parseargs/​unit_tests.rs Updates the conflict unit test.
tests/​by-util/​test_dd.rs Adds compatibility regression tests.
src/​uu/​dd/​locales/​en-US.ftl Removes the obsolete English error.
src/​uu/​dd/​locales/​fr-FR.ftl Removes the obsolete French error.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/by-util/test_dd.rs Outdated
Comment thread tests/by-util/test_dd.rs
Copilot AI balanced review requested due to automatic review settings October 13, 2026 00:20
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-dd-conv-conflicts branch from dbfc768 to a8f9cf0 Compare October 13, 2026 00: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.

🟢 Approval recommended

The focused implementation correctly handles conflict ordering, implied directions, and missing cbs, with adequate regression coverage.

0 open findings

🧠 Review effort: Balanced

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 04:52
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-dd-conv-conflicts branch from a8f9cf0 to 85e6280 Compare October 13, 2026 04:52

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.

🟢 Approval recommended

The focused implementation is consistent with the described behavior and has comprehensive regression coverage.

0 open findings

🧠 Review effort: Balanced

@sylvestre
sylvestre merged commit d0bc8a5 into uutils:main Oct 13, 2026
100 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

@ChihweiLHBird
ChihweiLHBird deleted the zhiwei/fix-dd-conv-conflicts branch October 13, 2026 13:32
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