mirror of https://github.com/sharkdp/bat.git
Compare commits
17 Commits
8d8c6bd691
...
1e83c1becc
Author | SHA1 | Date |
---|---|---|
John DeBoard | 1e83c1becc | |
John DeBoard | b05cde7ab4 | |
deboard | 2a29029828 | |
deboard | ac4f4b40df | |
John DeBoard | b1819cb09d | |
deboard | 10fd0b70e5 | |
deboard | ed6aad7835 | |
John DeBoard | e5858e27d9 | |
deboard | 1f3e3e0d71 | |
deboard | 635175ea64 | |
deboard | 7ae3185f47 | |
deboard | cb2f8f8210 | |
deboard | 76a655da5f | |
deboard | 6a0f6beab6 | |
deboard | 6b90c21ba3 | |
deboard | 6ea3ac71d7 | |
deboard | 54cec4a8e0 |
|
@ -9,7 +9,10 @@
|
|||
|
||||
## Bugfixes
|
||||
|
||||
- Send all bat error messages to stderr, see #2827 (@deboard)
|
||||
|
||||
- Fix long file name wrapping in header, see #2835 (@FilipRazek)
|
||||
-
|
||||
- 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 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();
|
||||
}
|
||||
_ => {
|
||||
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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -812,6 +812,16 @@ fn env_var_bat_pager_value_bat() {
|
|||
.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]
|
||||
fn pager_value_bat() {
|
||||
bat()
|
||||
|
@ -1284,6 +1294,9 @@ fn can_print_file_starting_with_cache() {
|
|||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_all_bat_error_to_stderr() {}
|
||||
|
||||
#[test]
|
||||
fn does_not_print_unwanted_file_named_cache() {
|
||||
bat_with_config().arg("cach").assert().failure();
|
||||
|
|
|
@ -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