share/config.fish: Quit if job expansion hack errors

This prevents something like `fg %5` to foreground the first job if
there is no fifth.

Fixes #9835
This commit is contained in:
Fabian Boehm 2023-06-10 15:35:44 +02:00
parent 65769bf8c8
commit 4e3b3b3b0a
2 changed files with 14 additions and 3 deletions

View file

@ -223,18 +223,21 @@ end
for jobbltn in bg wait disown
function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
set -l args (__fish_expand_pid_args $argv)
and builtin $jobbltn $args
end
end
function fg
builtin fg (__fish_expand_pid_args $argv)[-1]
set -l args (__fish_expand_pid_args $argv)
and builtin fg $args[-1]
end
if command -q kill
# Only define this if something to wrap exists
# this allows a nice "commad not found" error to be triggered.
function kill
command kill (__fish_expand_pid_args $argv)
set -l args (__fish_expand_pid_args $argv)
and command kill $args
end
end

View file

@ -125,3 +125,11 @@ sendline("wait 1")
expect_prompt("wait: Could not find a job with process id '1'")
sendline("wait hoge")
expect_prompt("wait: Could not find child processes with the name 'hoge'")
# See that we don't wait if job expansion fails
sendline("sleep 5m &")
expect_prompt()
sendline("wait %5")
expect_prompt("jobs: No suitable job: %5")
sendline("kill %1")
expect_prompt()