mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-24 19:48:22 +02:00
Merge b05cde7ab4
into ba49ba0acd
This commit is contained in:
commit
d90f975bfe
@ -53,7 +53,10 @@
|
|||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
|
|
||||||
|
- Send all bat error messages to stderr, see #2827 (@deboard)
|
||||||
|
|
||||||
- Fix long file name wrapping in header, see #2835 (@FilipRazek)
|
- Fix long file name wrapping in header, see #2835 (@FilipRazek)
|
||||||
|
-
|
||||||
- Fix `NO_COLOR` support, see #2767 (@acuteenvy)
|
- Fix `NO_COLOR` support, see #2767 (@acuteenvy)
|
||||||
- Fix handling of inputs with OSC ANSI escape sequences, see #2541 and #2544 (@eth-p)
|
- Fix handling of inputs with OSC ANSI escape sequences, see #2541 and #2544 (@eth-p)
|
||||||
- Fix handling of inputs with combined ANSI color and attribute sequences, see #2185 and #2856 (@eth-p)
|
- Fix handling of inputs with combined ANSI color and attribute sequences, see #2185 and #2856 (@eth-p)
|
||||||
|
10
src/error.rs
10
src/error.rs
@ -67,7 +67,15 @@ pub fn default_error_handler(error: &Error, output: &mut dyn Write) {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
writeln!(output, "{}: {}", Red.paint("[bat error]"), error).ok();
|
// default - always write [bat error] to stderr
|
||||||
|
let stderr = std::io::stderr();
|
||||||
|
writeln!(
|
||||||
|
&mut stderr.lock(),
|
||||||
|
"{}: {}",
|
||||||
|
Red.paint("[bat error]"),
|
||||||
|
error
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -861,6 +861,16 @@ fn env_var_bat_pager_value_bat() {
|
|||||||
.stderr(predicate::str::contains("bat as a pager is disallowed"));
|
.stderr(predicate::str::contains("bat as a pager is disallowed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bat_error_to_stderr() {
|
||||||
|
bat()
|
||||||
|
.env("BAT_PAGER", "bat")
|
||||||
|
.arg("/tmp")
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(predicate::str::contains("[bat error]"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pager_value_bat() {
|
fn pager_value_bat() {
|
||||||
bat()
|
bat()
|
||||||
@ -1358,6 +1368,9 @@ fn can_print_file_starting_with_cache() {
|
|||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn send_all_bat_error_to_stderr() {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn does_not_print_unwanted_file_named_cache() {
|
fn does_not_print_unwanted_file_named_cache() {
|
||||||
bat_with_config().arg("cach").assert().failure();
|
bat_with_config().arg("cach").assert().failure();
|
||||||
|
14
tests/scripts/stderr1.sh
Executable file
14
tests/scripts/stderr1.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## test for issue 2561
|
||||||
|
|
||||||
|
OUTPUT=$(mktemp)
|
||||||
|
BAT=bat
|
||||||
|
code=$($BAT /tmp 2> $OUTPUT; cat $OUTPUT | grep error; echo $?)
|
||||||
|
|
||||||
|
if [[ $code == 1 ]]; then
|
||||||
|
echo "stderr test fsil"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user