Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

echo: Argument is treated as multiple arguments #1873

Closed
DoBi opened this issue Mar 22, 2021 · 1 comment · Fixed by #1887
Closed

echo: Argument is treated as multiple arguments #1873

DoBi opened this issue Mar 22, 2021 · 1 comment · Fixed by #1887
Labels
good first issue For newcomers!

Comments

@DoBi
Copy link
Contributor

DoBi commented Mar 22, 2021

I just found out, that there is a different behaviour between the C-coreutils echo and the Rust version.

This command leads to an error, while working with the C version:

echo '"\n'CXXFLAGS=-g -O2'\n"'

It leads to this output:

echo '"\n'CXXFLAGS=-g -O2'\n"'
echo: error: Unrecognized option: 'O'

The expected output is:

echo '"\n'CXXFLAGS=-g -O2'\n"'
"\nCXXFLAGS=-g -O2\n"

It seems like the argument is somehow parsed wrong.

@alstolten
Copy link
Contributor

alstolten commented Mar 22, 2021

In #1886 I created a failing test case for this. Unfortunately https://docs.rs/clap/2.33.3/clap/struct.Arg.html#method.allow_hyphen_values does not help.

ycd added a commit to ycd/coreutils that referenced this issue Mar 23, 2021
sylvestre pushed a commit that referenced this issue Mar 23, 2021
* fix: use settings to allow leading hyphen and trailing var arg

fixes: #1873

* test: add test cases

* test: add more test cases with different order in hyphen values

* chore: add comment to explain why we need TrailingVarArg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue For newcomers!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants