coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

gnucompability(tail): -c accepts some large units that gnu rejects

Open HackingRepo opened this issue 5 months ago • 6 comments

Hi, uutils mainteners

we confirmed that the uu tail -c accepted, some large units, without errors

relunsec@relunsec:~/software/coreutils/target/debug$ ./tail -c2z a
hello
relunsec@relunsec:~/software/coreutils/target/debug$ gnutail -c2z a
gnutail: invalid number of bytes: ‘2z’
relunsec@relunsec:~/software/coreutils/target/debug$ ./tail -c2e a
hello
relunsec@relunsec:~/software/coreutils/target/debug$ gnutail -c2e a
gnutail: invalid number of bytes: ‘2e’
relunsec@relunsec:~/software/coreutils/target/debug$ ./tail -c2g a
hello
relunsec@relunsec:~/software/coreutils/target/debug$ gnutail -c2g a
gnutail: invalid number of bytes: ‘2g’
relunsec@relunsec:~/software/coreutils/target/debug$ 
relunsec@relunsec:~/software/coreutils/target/debug$ ./tail -c2t a
hello
relunsec@relunsec:~/software/coreutils/target/debug$ gnutail -c2t a
gnutail: invalid number of bytes: ‘2t’
relunsec@relunsec:~/software/coreutils/target/debug$ 

HackingRepo avatar Jun 27 '26 16:06 HackingRepo

We should not ivergent interface, but I think we can accept them as extension.

oech3 avatar Jun 27 '26 16:06 oech3

yes make that a cargo feature, i think

HackingRepo avatar Jun 27 '26 16:06 HackingRepo

By defautl, not as optional feature.

oech3 avatar Jun 28 '26 05:06 oech3

ok

HackingRepo avatar Jun 28 '26 08:06 HackingRepo

Should we modify the path resolution public library?

tuxnode avatar Jul 01 '26 17:07 tuxnode

I'd like to work on this.

tail and head both parse their count argument through the same parse_signed_num_max helper, which uses the generic size parser with no allow list, so they accept every suffix that parser knows. I compared against GNU coreutils 9.11 by running the binaries and the accepted set for both utilities is the same: bare b, plus k m K M G T P E Z Y R Q each also valid with a B, iB or D suffix. Lowercase g t e z y r q p and a bare B/D are rejected, and b is bare-only.

I'll restrict the shared helper to that set and add tests for both utilities.

kennywillbe avatar Aug 29 '26 11:08 kennywillbe