Skip to content

uniq: take digits after -f, -s or -w as their value - #16867

Merged
sylvestre merged 2 commits into
uutils:mainfrom
binhvq:uniq-cluster-option-value
Nov 27, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
binhvq:uniq-cluster-option-value

Conversation

@binhvq

@binhvq binhvq commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

In a cluster like -cf2, the digits after f, s or w were read as the obsolete -N field count, which left the option without a value. Digits are now only taken as -N before one of those letters.

Closes #16866

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

Comment thread tests/by-util/test_uniq.rs Outdated
#[rstest]
#[case::skip_fields("-cf2", " 3 a x 1\n 1 d z 2\n")]
#[case::skip_chars("-us4", "d z 2\n")]
#[case::check_chars("-cw1", " 1 a x 1\n 1 b y 1\n 1 c y 1\n 1 d z 2\n")]

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.

with this input the output is the same without -w1, could you use lines where it matters? (e.g. "ab\nac\n")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, changed the input to a x 1\na y 1\nc y 1\nd z 2\n so -cw1 folds the first two lines (plain -c keeps all four apart). The other two cases give the same output as before.

In a cluster like -cf2 the digits were read as the obsolete -N field count, which left -f without a value.
@sylvestre
sylvestre force-pushed the uniq-cluster-option-value branch from 8010313 to 4bcc2cf Compare November 27, 2026 12:14
Comment thread src/uu/uniq/src/uniq.rs
obs_overwritten_by_new = true;
}
// Digits after -f, -s or -w are that option's value, as in `-cf2`
if matches!(*c, 'f' | 's' | 'w') {

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.

maybe it should be an enum in the future

@sylvestre
sylvestre merged commit ab69b86 into uutils:main Nov 27, 2026
143 of 144 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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.

uniq: digits after -f, -s or -w in a cluster are read as -N

2 participants