From 49f8c96054dd734a859db29c2acd45af47764ac0 Mon Sep 17 00:00:00 2001 From: arbelonson-source <269032023+arbelonson-source@users.noreply.github.com> Date: Mon, 31 Aug 2026 09:46:17 +0300 Subject: [PATCH] join: accept a hyphen-leading -t separator, quote it in the error -t's value was rejected as an unrecognized flag when given as its own argument (`join -t -x f1 f2`, not the attached `-tx` or `-t=x`): the Arg was missing allow_hyphen_values, which every other option fixed this way this session was too. GNU's own -t accepts any single argument as the separator regardless of its first character. Also quotes the value in the resulting "multi-character tab" message to match GNU (`multi-character tab 'ab'`, not `multi-character tab ab`) -- a separate, pre-existing bug in the same message that this fix's own test would otherwise still fail against, since a hyphen-leading multi-character value now reaches the exact same message construction as any other one. AI-assisted-by: Claude Opus 5, via Claude Code --- src/uu/join/locales/en-US.ftl | 2 +- src/uu/join/locales/fr-FR.ftl | 2 +- src/uu/join/src/join.rs | 1 + tests/by-util/test_join.rs | 16 +++++++++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/uu/join/locales/en-US.ftl b/src/uu/join/locales/en-US.ftl index 04cc94fd013..c23cf02e897 100644 --- a/src/uu/join/locales/en-US.ftl +++ b/src/uu/join/locales/en-US.ftl @@ -24,7 +24,7 @@ join-help-z = line delimiter is NUL, not newline join-error-io = io error: { $error } join-error-non-utf8-tab = non-UTF-8 multi-byte tab join-error-unprintable-separators = unprintable field separators are only supported on unix-like platforms -join-error-multi-character-tab = multi-character tab { $value } +join-error-multi-character-tab = multi-character tab '{ $value }' join-error-both-files-stdin = both files cannot be standard input join-error-invalid-field-specifier = invalid field specifier: { $spec } join-error-invalid-file-number = invalid file number in field spec: { $spec } diff --git a/src/uu/join/locales/fr-FR.ftl b/src/uu/join/locales/fr-FR.ftl index eac430b5d55..7f947cf600e 100644 --- a/src/uu/join/locales/fr-FR.ftl +++ b/src/uu/join/locales/fr-FR.ftl @@ -24,7 +24,7 @@ join-help-z = le délimiteur de ligne est NUL, pas de nouvelle ligne join-error-io = erreur d'E/S : { $error } join-error-non-utf8-tab = tabulation multi-octets non-UTF-8 join-error-unprintable-separators = les séparateurs de champs non imprimables ne sont pris en charge que sur les plateformes de type unix -join-error-multi-character-tab = tabulation multi-caractères { $value } +join-error-multi-character-tab = tabulation multi-caractères '{ $value }' join-error-both-files-stdin = les deux fichiers ne peuvent pas être l'entrée standard join-error-invalid-field-specifier = spécificateur de champ invalide : { $spec } join-error-invalid-file-number = numéro de fichier invalide dans la spécification de champ : { $spec } diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 445e1641642..6b3188ed115 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -947,6 +947,7 @@ pub fn uu_app() -> Command { .short('t') .value_name("CHAR") .value_parser(ValueParser::os_string()) + .allow_hyphen_values(true) .help(translate!("join-help-t")), ) .arg( diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index a5ad3b619d6..51c9999820f 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -231,7 +231,21 @@ fn tab_multi_character() { .arg("-t") .arg("ab") .fails() - .stderr_is("join: multi-character tab ab\n"); + .stderr_is("join: multi-character tab 'ab'\n"); +} + +#[test] +fn tab_hyphen_leading_as_separate_arg() { + // A hyphen-leading separator value passed as its own argument (not + // attached with `-t-x`/`=`) must not be mistaken for a new, + // unrecognized flag. + new_ucmd!() + .arg("semicolon_fields_1.txt") + .arg("semicolon_fields_2.txt") + .arg("-t") + .arg("-x") + .fails() + .stderr_is("join: multi-character tab '-x'\n"); } #[test]