From 1e9d69bd8546178eee75e6fb09a9553c31db85fa Mon Sep 17 00:00:00 2001 From: arbelonson-source <269032023+arbelonson-source@users.noreply.github.com> Date: Mon, 31 Aug 2026 09:50:01 +0300 Subject: [PATCH] paste: accept a hyphen-leading -d delimiter list -d's value was rejected as an unrecognized flag when given as its own argument (paste -d -x f1 f2, not the attached -d-x or -d=-x): the Arg was missing allow_hyphen_values, the same gap already fixed this session for several other options (sort --parallel, nl's numeric options, ptx --gap-size/--width, join -t, csplit --suffix-format). GNU's own -d accepts any argument as the delimiter list regardless of its first character. AI-assisted-by: Claude Opus 5, via Claude Code --- src/uu/paste/src/paste.rs | 1 + tests/by-util/test_paste.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index 2a7f896c34b..f12a85a663d 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -65,6 +65,7 @@ pub fn uu_app() -> Command { .value_name("LIST") .default_value("\t") .hide_default_value(true) + .allow_hyphen_values(true) .value_parser(clap::value_parser!(OsString)), ) .arg( diff --git a/tests/by-util/test_paste.rs b/tests/by-util/test_paste.rs index c07b0fcaaa5..4d9c8ca7e36 100644 --- a/tests/by-util/test_paste.rs +++ b/tests/by-util/test_paste.rs @@ -166,6 +166,19 @@ fn test_invalid_arg() { new_ucmd!().arg("--definitely-invalid").fails_with_code(1); } +#[test] +fn test_delimiter_hyphen_leading_as_separate_arg() { + // A hyphen-leading delimiter value passed as its own argument (not + // attached with `-d-x`/`=`) must not be mistaken for a new, + // unrecognized flag. + let (at, mut ucmd) = at_and_ucmd!(); + at.write("f1", "a\nb\n"); + at.write("f2", "1\n2\n"); + ucmd.args(&["-d", "-x", "f1", "f2"]) + .succeeds() + .stdout_is("a-1\nb-2\n"); +} + #[test] fn test_combine_pairs_of_lines() { for s in ["-s", "--serial"] {