coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

echo: arguments should be printed when multiple long args are passed

Open SaHHiiLL opened this issue 1 year ago • 4 comments

GNU

$ /bin/echo --version --help
--version --help

coreutils

$ cargo run --features unix -- echo --version --help
echo 0.0.24

for the short commands, if you do in GNU

$ /bin/echo -n --version
--version%

in coreutils

$ cargo run --features unix -- echo -n --version
echo 0.0.24

PS: is the same behavior if you change --version to --help will just get help section instead of version

SaHHiiLL avatar Jan 29 '24 17:01 SaHHiiLL

additionally switching the order produces a different result :p GNU

$ /bin/echo --version -n
--version -n

SaHHiiLL avatar Jan 29 '24 17:01 SaHHiiLL

Isn't echo fun? 😄 Do you want to attempt a PR this?

tertsdiepraam avatar Jan 29 '24 17:01 tertsdiepraam

Haha sure is!

Do you want to attempt a PR this?

I don't know, not too familiar with the code base. What I am thinking is ditching clap for echo and parse the args the manually which would bring it closer to GNU but would compromise the code quality. Though if i do that it might also fix #5840

SaHHiiLL avatar Jan 29 '24 17:01 SaHHiiLL

I've been working on special-casing it in the new parser. I think it might be worth a shot to customize it completely, if only to make a test suite with all the cases that the new parser will need to handle. The clap parser still needs to exist to print the help and to generate the manpages and completion, but we can ignore it for the actual parsing.

@sylvestre @cakebaker what's your opinion?

tertsdiepraam avatar Jan 29 '24 18:01 tertsdiepraam