mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-01 01:34:00 +08:00
fix builtin help ignoring redirects (#10276)
* fix builtin help ignoring redirects * test builtin help redirects
This commit is contained in:
parent
b265152fba
commit
508ea59dcd
|
@ -1,7 +1,7 @@
|
|||
use super::prelude::*;
|
||||
use crate::builtins::*;
|
||||
use crate::common::{escape, get_by_sorted_name, str2wcstring, Named};
|
||||
use crate::io::{IoChain, IoFd, OutputStream};
|
||||
use crate::io::{IoFd, OutputStream};
|
||||
use crate::parse_constants::UNKNOWN_BUILTIN_ERR_MSG;
|
||||
use crate::parse_util::parse_util_argument_is_help;
|
||||
use crate::parser::{Block, BlockType, LoopStatus};
|
||||
|
@ -553,7 +553,7 @@ pub fn builtin_print_help_error(
|
|||
}
|
||||
let name_esc = escape(cmd);
|
||||
let mut cmd = sprintf!("__fish_print_help %ls ", &name_esc);
|
||||
let mut ios = IoChain::new();
|
||||
let mut ios = streams.io_chain.clone();
|
||||
if !error_message.is_empty() {
|
||||
cmd.push_utfstr(&escape(error_message));
|
||||
// If it's an error, redirect the output of __fish_print_help to stderr
|
||||
|
|
15
tests/checks/print-help.fish
Normal file
15
tests/checks/print-help.fish
Normal file
|
@ -0,0 +1,15 @@
|
|||
# RUN: %fish %s
|
||||
# Test redirecting builtin help with a pipe
|
||||
|
||||
set -lx __fish_data_dir (mktemp -d)
|
||||
mkdir -p $__fish_data_dir/man/man1
|
||||
# Create $__fish_data_dir/man/man1/and.1
|
||||
echo '.\" Test manpage for and (not real).
|
||||
.TH "AND" "1" "Feb 02, 2024" "3.7" "fish-shell"
|
||||
.SH NAME
|
||||
and \- conditionally execute a command' >$__fish_data_dir/man/man1/and.1
|
||||
|
||||
# help should be redirected to grep instead of appearing on STDOUT
|
||||
builtin and --help | grep -q "and - conditionally execute a command"
|
||||
echo $status
|
||||
#CHECK: 0
|
Loading…
Reference in New Issue
Block a user