mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #2899 from cohosh/join_chkodr_error_fix
join: print unsorted line in error message
This commit is contained in:
commit
8c53854aca
2 changed files with 13 additions and 5 deletions
|
@ -235,6 +235,7 @@ impl Spec {
|
||||||
|
|
||||||
struct Line {
|
struct Line {
|
||||||
fields: Vec<Vec<u8>>,
|
fields: Vec<Vec<u8>>,
|
||||||
|
string: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Line {
|
impl Line {
|
||||||
|
@ -247,10 +248,10 @@ impl Line {
|
||||||
.map(Vec::from)
|
.map(Vec::from)
|
||||||
.collect(),
|
.collect(),
|
||||||
Sep::Char(sep) => string.split(|c| *c == sep).map(Vec::from).collect(),
|
Sep::Char(sep) => string.split(|c| *c == sep).map(Vec::from).collect(),
|
||||||
Sep::Line => vec![string],
|
Sep::Line => vec![string.clone()],
|
||||||
};
|
};
|
||||||
|
|
||||||
Line { fields }
|
Line { fields, string }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get field at index.
|
/// Get field at index.
|
||||||
|
@ -444,9 +445,11 @@ impl<'a> State<'a> {
|
||||||
|
|
||||||
if diff == Ordering::Greater {
|
if diff == Ordering::Greater {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}:{}: is not sorted",
|
"{}: {}:{}: is not sorted: {}",
|
||||||
|
uucore::execution_phrase(),
|
||||||
self.file_name.maybe_quote(),
|
self.file_name.maybe_quote(),
|
||||||
self.line_num
|
self.line_num,
|
||||||
|
String::from_utf8_lossy(&line.string)
|
||||||
);
|
);
|
||||||
|
|
||||||
// This is fatal if the check is enabled.
|
// This is fatal if the check is enabled.
|
||||||
|
|
|
@ -283,11 +283,16 @@ fn missing_format_fields() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn wrong_line_order() {
|
fn wrong_line_order() {
|
||||||
|
let ts = TestScenario::new(util_name!());
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("fields_2.txt")
|
.arg("fields_2.txt")
|
||||||
.arg("fields_4.txt")
|
.arg("fields_4.txt")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("fields_4.txt:5: is not sorted");
|
.stderr_is(&format!(
|
||||||
|
"{} {}: fields_4.txt:5: is not sorted: 11 g 5 gh",
|
||||||
|
ts.bin_path.to_string_lossy(),
|
||||||
|
ts.util_name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue