Allow fish_indent builtin to be redirected

Missed write_to_fd calls

Not in 4.0 because fish_indent isn't a builtin there.

This requires str2wcstring, which is awkward but it's not performance-sensitive.

Fixes #11146
This commit is contained in:
Fabian Boehm
2025-02-11 22:19:44 +01:00
parent 3350145371
commit b6fe6b7bf4
2 changed files with 8 additions and 4 deletions

View File

@@ -12,7 +12,7 @@
use std::os::unix::ffi::OsStrExt;
use crate::panic::panic_handler;
use libc::{LC_ALL, STDOUT_FILENO};
use libc::LC_ALL;
use super::prelude::*;
use crate::ast::{
@@ -41,7 +41,7 @@
use crate::wchar::prelude::*;
use crate::wcstringutil::count_preceding_backslashes;
use crate::wgetopt::{wopt, ArgType, WGetopter, WOption};
use crate::wutil::{fish_iswalnum, write_to_fd};
use crate::wutil::fish_iswalnum;
/// Note: this got somewhat more complicated after introducing the new AST, because that AST no
/// longer encodes detailed lexical information (e.g. every newline). This feels more complex
@@ -977,7 +977,7 @@ enum OutputType {
if output_type == OutputType::PygmentsCsv {
let output = make_pygments_csv(&src);
let _ = write_to_fd(&output, STDOUT_FILENO);
streams.out.append(str2wcstring(&output));
i += 1;
continue;
}
@@ -1075,7 +1075,7 @@ enum OutputType {
}
}
let _ = write_to_fd(&colored_output, STDOUT_FILENO);
streams.out.append(str2wcstring(&colored_output));
i += 1;
}
retval

View File

@@ -608,3 +608,7 @@ echo 'echo "foo" "bar"' > $tmpdir/indent_test.fish
$fish_indent --write $tmpdir/indent_test.fish
cat $tmpdir/indent_test.fish
# CHECK: echo foo bar
# See that the builtin can be redirected
printf %s\n a b c | builtin fish_indent | grep b
# CHECK: b