mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 04:45:04 +02:00
Don't panic if the other end of std{out,err} is closed (#4179)
* fix #4161 println! and friends will panic on BrokenPipe. The solution is to use writeln! instead, and ignore the error (or do we want to do something else?) * test that nu doesn't panic in case of BrokenPipe error * fixup! test that nu doesn't panic in case of BrokenPipe error * make do_not_panic_if_broken_pipe only run on UNIX systems
This commit is contained in:
committed by
GitHub
parent
e919f9a73b
commit
d32aec5906
@ -6,7 +6,7 @@
|
||||
macro_rules! out {
|
||||
($($tokens:tt)*) => {
|
||||
use std::io::Write;
|
||||
print!($($tokens)*);
|
||||
write!(std::io::stdout(), $($tokens)*).unwrap_or(());
|
||||
let _ = std::io::stdout().flush();
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,12 @@ macro_rules! out {
|
||||
/// and stray printlns left by accident
|
||||
#[macro_export]
|
||||
macro_rules! outln {
|
||||
($($tokens:tt)*) => { println!($($tokens)*) }
|
||||
($($tokens:tt)*) => {
|
||||
{
|
||||
use std::io::Write;
|
||||
writeln!(std::io::stdout(), $($tokens)*).unwrap_or(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Outputs to standard error
|
||||
@ -26,7 +31,12 @@ macro_rules! outln {
|
||||
/// and stray printlns left by accident
|
||||
#[macro_export]
|
||||
macro_rules! errln {
|
||||
($($tokens:tt)*) => { eprintln!($($tokens)*) }
|
||||
($($tokens:tt)*) => {
|
||||
{
|
||||
use std::io::Write;
|
||||
writeln!(std::io::stderr(), $($tokens)*).unwrap_or(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
Reference in New Issue
Block a user