Compare commits

...

17 Commits

Author SHA1 Message Date
John DeBoard 1e83c1becc
Merge b05cde7ab4 into 66b70dd8ed 2024-04-14 19:01:02 +05:45
John DeBoard b05cde7ab4
Merge branch 'master' into issue#2561 2024-02-02 09:19:02 -05:00
deboard 2a29029828 Merge branch 'issue#2561' of github.com:deboard/bat into issue#2561 2024-01-22 20:23:35 -05:00
deboard ac4f4b40df Ran cargo fmt. 2024-01-22 20:23:20 -05:00
John DeBoard b1819cb09d
Merge branch 'master' into issue#2561 2024-01-22 20:10:41 -05:00
deboard 10fd0b70e5 Add integration test. 2024-01-22 20:06:41 -05:00
deboard ed6aad7835 Add test. 2024-01-05 23:20:47 -05:00
John DeBoard e5858e27d9
Merge branch 'master' into issue#2561 2024-01-04 10:04:36 -05:00
deboard 1f3e3e0d71 Ammend CHANGELOG... Again... 2024-01-03 05:38:53 -05:00
deboard 635175ea64 Ammend CHANGELOG... Again... 2024-01-03 05:37:56 -05:00
deboard 7ae3185f47 Merge branch 'issue#2561' of github.com:deboard/bat into issue#2561 2024-01-02 19:09:10 -05:00
deboard cb2f8f8210 Ammend CHANGELOG... Again 2024-01-02 19:08:16 -05:00
deboard 76a655da5f Merge branch 'issue#2561' of github.com:deboard/bat into issue#2561 2024-01-02 19:03:02 -05:00
deboard 6a0f6beab6 Ammend CHANGELOG 2024-01-02 19:02:26 -05:00
deboard 6b90c21ba3 Merge branch 'issue#2561' of github.com:deboard/bat into issue#2561 2024-01-02 18:01:34 -05:00
deboard 6ea3ac71d7 issue 2561, send all [bat error]s to stderr in default_error_handler
match default.
2024-01-02 17:54:49 -05:00
deboard 54cec4a8e0 issue 2561, send all [bat error]s to stderr in default_error_handler
match default.
2024-01-02 17:44:27 -05:00
4 changed files with 39 additions and 1 deletions

View File

@ -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)

View File

@ -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();
}
};
}

View File

@ -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();

14
tests/scripts/stderr1.sh Executable file
View 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