diff --git a/src/uu/unexpand/src/unexpand.rs b/src/uu/unexpand/src/unexpand.rs index d45da4ba46..0d26088bc0 100644 --- a/src/uu/unexpand/src/unexpand.rs +++ b/src/uu/unexpand/src/unexpand.rs @@ -48,7 +48,8 @@ fn parse_tab_num(word: &str, allow_zero: bool) -> Result { } fn parse_tabstops(s: &str) -> Result { - let words = s.split(','); + // GNU accepts a blank (space or tab) or a comma as tab-list separators. + let words = s.split([' ', '\t', ',']); let mut nums = Vec::new(); let mut increment_size: Option = None; diff --git a/tests/by-util/test_unexpand.rs b/tests/by-util/test_unexpand.rs index be30d46d0d..ae9d86aae1 100644 --- a/tests/by-util/test_unexpand.rs +++ b/tests/by-util/test_unexpand.rs @@ -270,6 +270,18 @@ fn test_comma_separated_tabs_shortcut() { .stdout_is("a\tb\tc"); } +#[test] +fn test_blank_separated_tabs() { + // GNU accepts a space or a tab as a tab-list separator, just like a comma. + for sep in [" ", "\t"] { + new_ucmd!() + .args(&["-a", "-t", &format!("3{sep}9")]) + .pipe_in("a b c") + .succeeds() + .stdout_is("a\tb\tc"); + } +} + #[test] fn test_tabs_cannot_be_zero() { new_ucmd!()