echo: fix duplication of -- arguments#7559
echo: fix duplication of -- arguments#7559Expertcoderz wants to merge 4 commits intouutils:mainfrom Expertcoderz:main
-- arguments#7559Conversation
Fixes #7558. Previously, a workaround for handling double hyphens had the erroneous side effect of echoing `--` twice in a row if the `--` is the first double hyphen to be passed on the argument list and it is also not the first argument to `echo`. This commit fixes the aforementioned issue.
|
Can you please add a test to ensure that we don't regress in the future? |
Sure, working on it. Give me a moment as this is my first time on a Rust project. |
This adds a test for passing `--` as a non-first argument to `echo`. Fixes #7558.
|
A test has been added. It successfully catches the |
|
GNU testsuite comparison: |
It looks like you introduced a new bug ;-) |
Adds a word to the `spell-checker:ignore` to prevent spellcheck from failing due to said word being introduced in fb2a276.
Whoopsies, I'll have a look at the code and see what other changes must be made. |
|
GNU testsuite comparison: |
Fixes a bug introduced by fcf00a0 as mentioned by @cakebaker. `echo -n -e --` no longer eats the double hyphen. However, this commit also reduces the double-hyphen duplication fix that fcf00a0 was supposed to introduce to a partial fix. The following example will cause double-hyphen duplication: ```sh $ cargo run -q echo -nonsense -- -nonsense -- -- ``` To fix that as well, a more involved workaround may be necessary.
|
I've pushed a commit that fixes the bug triggered when specifying # works:
$ cargo run -q echo -n -e -- hi
-- hi
# works:
$ cargo run -q echo -- hi
-- hi
# works:
$ cargo run -q echo hi --
hi --
# fails:
# (where `-x` is an arbitrary argument that starts with `-` but is not a valid flag)
$ cargo run -q echo -x -- hi
-x -- -- hiIt looks like what we need is either:
|
|
GNU testsuite comparison: |
|
Closing this PR, superseded by #7581. @Expertcoderz thanks for your work on this PR! |
Fixes #7558.
Previously, a workaround for handling double hyphens had the erroneous side effect of echoing
--twice in a row if the--is the first double hyphen to be passed on the argument list and it is also not the first argument toecho. This commit fixes the aforementioned issue.