mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-24 17:12:16 +02:00
parent
f02a50a69d
commit
c8e4a84519
@ -39,21 +39,29 @@ macro_rules! eprintln_locked {
|
|||||||
// lock stdout before printing to stderr. This avoids interleaving
|
// lock stdout before printing to stderr. This avoids interleaving
|
||||||
// lines within ripgrep because `search_parallel` uses `termcolor`,
|
// lines within ripgrep because `search_parallel` uses `termcolor`,
|
||||||
// which accesses the same stdout lock when writing lines.
|
// which accesses the same stdout lock when writing lines.
|
||||||
let stdout = std::io::stdout();
|
let stdout = std::io::stdout().lock();
|
||||||
let _handle = stdout.lock();
|
let mut stderr = std::io::stderr().lock();
|
||||||
// We specifically ignore any errors here. One plausible error we
|
// We specifically ignore any errors here. One plausible error we
|
||||||
// can get in some cases is a broken pipe error. And when that
|
// can get in some cases is a broken pipe error. And when that
|
||||||
// occurs, we should exit gracefully. Otherwise, just abort with
|
// occurs, we should exit gracefully. Otherwise, just abort with
|
||||||
// an error code because there isn't much else we can do.
|
// an error code because there isn't much else we can do.
|
||||||
//
|
//
|
||||||
// See: https://github.com/BurntSushi/ripgrep/issues/1966
|
// See: https://github.com/BurntSushi/ripgrep/issues/1966
|
||||||
if let Err(err) = writeln!(std::io::stderr(), $($tt)*) {
|
if let Err(err) = write!(stderr, "rg: ") {
|
||||||
if err.kind() == std::io::ErrorKind::BrokenPipe {
|
if err.kind() == std::io::ErrorKind::BrokenPipe {
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
} else {
|
} else {
|
||||||
std::process::exit(2);
|
std::process::exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Err(err) = writeln!(stderr, $($tt)*) {
|
||||||
|
if err.kind() == std::io::ErrorKind::BrokenPipe {
|
||||||
|
std::process::exit(0);
|
||||||
|
} else {
|
||||||
|
std::process::exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drop(stdout);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
@ -975,7 +975,7 @@ rgtest!(f1404_nothing_searched_warning, |dir: Dir, mut cmd: TestCommand| {
|
|||||||
let output = cmd.raw_output();
|
let output = cmd.raw_output();
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
let expected = "\
|
let expected = "\
|
||||||
No files were searched, which means ripgrep probably applied \
|
rg: No files were searched, which means ripgrep probably applied \
|
||||||
a filter you didn't expect.\n\
|
a filter you didn't expect.\n\
|
||||||
Running with --debug will show why files are being skipped.\n\
|
Running with --debug will show why files are being skipped.\n\
|
||||||
";
|
";
|
||||||
|
@ -402,7 +402,7 @@ rgtest!(r428_unrecognized_style, |dir: Dir, mut cmd: TestCommand| {
|
|||||||
let output = cmd.raw_output();
|
let output = cmd.raw_output();
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
let expected = "\
|
let expected = "\
|
||||||
error parsing flag --colors: \
|
rg: error parsing flag --colors: \
|
||||||
unrecognized style attribute ''. Choose from: nobold, bold, nointense, \
|
unrecognized style attribute ''. Choose from: nobold, bold, nointense, \
|
||||||
intense, nounderline, underline.
|
intense, nounderline, underline.
|
||||||
";
|
";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user