Skip to content

Commit fcf00a0

Browse files
committed
echo: fix duplication of -- arguments
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.
1 parent cce6e49 commit fcf00a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/uu/echo/src/echo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ fn handle_double_hyphens(args: impl uucore::Args) -> impl uucore::Args {
2929
let mut result = Vec::new();
3030
let mut is_first_double_hyphen = true;
3131

32-
for arg in args {
33-
if arg == "--" && is_first_double_hyphen {
32+
for (i, arg) in args.enumerate() {
33+
if i < 2 && arg == "--" && is_first_double_hyphen {
3434
result.push(OsString::from("--"));
3535
is_first_double_hyphen = false;
3636
}

0 commit comments

Comments
 (0)