From 109277d4055641ff084ff6488c77cf80b22f1d13 Mon Sep 17 00:00:00 2001 From: Justin Tracey Date: Thu, 6 Jan 2022 02:20:01 -0500 Subject: [PATCH] join: add support for `-t '\0'` --- src/uu/join/src/join.rs | 1 + tests/by-util/test_join.rs | 11 +++++++++++ tests/fixtures/join/null-sep.expected | Bin 0 -> 12 bytes 3 files changed, 12 insertions(+) create mode 100644 tests/fixtures/join/null-sep.expected diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 0c881f20d..55bd1b2c5 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -503,6 +503,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { settings.separator = match value.len() { 0 => Sep::Line, 1 => Sep::Char(value[0]), + 2 if value[0] == b'\\' && value[1] == b'0' => Sep::Char(0), _ => { return Err(USimpleError::new( 1, diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index be25b9390..c3c34b856 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -346,3 +346,14 @@ fn non_unicode() { .succeeds() .stdout_only_fixture("non-unicode.expected"); } + +#[test] +fn null_field_separators() { + new_ucmd!() + .arg("-t") + .arg("\\0") + .arg("non-unicode_1.bin") + .arg("non-unicode_2.bin") + .succeeds() + .stdout_only_fixture("null-sep.expected"); +} diff --git a/tests/fixtures/join/null-sep.expected b/tests/fixtures/join/null-sep.expected new file mode 100644 index 0000000000000000000000000000000000000000..7d91c578215b55c04e41f7515ef199e6874e208a GIT binary patch literal 12 TcmYdPSk92bkj#*xkj4c76t)87 literal 0 HcmV?d00001