Fix spurious status=1 from calling binding function from config

A command like "fish -C fish_default_key_bindings" shows a exit status
of 1 in the default prompt. Fix that.
This commit is contained in:
Johannes Altmanninger
2026-01-11 16:29:15 +01:00
parent de2ac37c92
commit b9dfbcee13
3 changed files with 6 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ function __fish_change_key_bindings --argument-names bindings
# We try to use `set --no-event`, but to avoid leaving the user without bindings
# if they run this with an older version we fall back on setting the variable
# with an event.
true
if ! set --no-event $scope fish_key_bindings $bindings 2>/dev/null
# This triggers the handler, which calls us again
set $scope fish_key_bindings $bindings

View File

@@ -7,6 +7,7 @@ set -l tmpdir (mktemp -d)
for bindings in true fish_default_key_bindings fish_vi_key_bindings
$fish -c "
$bindings
or echo >&2 error setting bindings: status=\$status
bind > $tmpdir/old
bind --erase --all --preset
bind --erase --all

View File

@@ -3,6 +3,8 @@
fish_vi_key_bindings
commandline '1'; commandline --cursor 0; fish_vi_dec
# CHECK: {{\x1b\[6 q}}
echo
commandline --current-buffer
# CHECK: 0
@@ -113,3 +115,5 @@ commandline --current-buffer
commandline 'to 2022-04-09'; commandline --cursor 11; fish_vi_inc
commandline --current-buffer
# CHECK: to 2022-04-08
# CHECK: {{\x1b\[2 q}}