mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #2525 from miDeb/sort/nul-tab
sort: allow null bytes for -t
This commit is contained in:
commit
56cc2cdd67
2 changed files with 13 additions and 1 deletions
|
@ -1065,7 +1065,10 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
if let Some(arg) = matches.args.get(options::SEPARATOR) {
|
if let Some(arg) = matches.args.get(options::SEPARATOR) {
|
||||||
let separator = arg.vals[0].to_string_lossy();
|
let separator = arg.vals[0].to_string_lossy();
|
||||||
let separator = separator;
|
let mut separator = separator.as_ref();
|
||||||
|
if separator == "\\0" {
|
||||||
|
separator = "\0";
|
||||||
|
}
|
||||||
if separator.len() != 1 {
|
if separator.len() != 1 {
|
||||||
crash!(1, "separator must be exactly one character long");
|
crash!(1, "separator must be exactly one character long");
|
||||||
}
|
}
|
||||||
|
|
|
@ -959,3 +959,12 @@ fn test_key_takes_one_arg() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is_fixture("keys_open_ended.expected");
|
.stdout_is_fixture("keys_open_ended.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_separator_null() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-k1,1", "-k3,3", "-t", "\\0"])
|
||||||
|
.pipe_in("z\0a\0b\nz\0b\0a\na\0z\0z\n")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_only("a\0z\0z\nz\0b\0a\nz\0a\0b\n");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue