builtin fish_indent/fish_key_reader: call help from existing fish process

Something like

	PATH=mypath builtin fish_indent --help

runs "fish -c '__fish_print_help fish_indent'" internally.  Since we
don't call setenv(), the PATH update doesn't reach the child shell.
Fix this by using what other builtins use if we are one (i.e. if we
have a Parser in context).

Fixes #12229
Maybe also #12085
This commit is contained in:
Johannes Altmanninger
2026-01-04 06:49:13 +01:00
parent 756134cf2b
commit 5d8f7801f7
3 changed files with 34 additions and 10 deletions

View File

@@ -656,3 +656,9 @@ printf %s\n a b c | builtin fish_indent | grep b
# Regression test that fish_indent doesn't panic with closed stdin.
fish_indent <&-
# CHECKERR: fish_indent: stdin is closed
function __fish_print_help
echo Help using PATH[1]=$PATH[1]
end
PATH=hello fish_indent --help
# CHECK: Help using PATH[1]=hello