fish-shell/tests/checks/jobs.fish

59 lines
1.1 KiB
Fish
Raw Normal View History

2020-02-08 08:44:39 +00:00
#RUN: %fish %s
2018-03-04 21:33:36 +00:00
jobs -q; echo $status
2020-02-08 08:44:39 +00:00
#CHECK: 1
sleep 5 &
sleep 5 &
2016-06-08 23:09:29 +00:00
jobs -c
2020-02-08 08:44:39 +00:00
#CHECK: Command
#CHECK: sleep
#CHECK: sleep
2018-03-04 21:33:36 +00:00
jobs -q; echo $status
2020-02-08 08:44:39 +00:00
#CHECK: 0
bg -23 1 2>/dev/null
2017-06-15 01:25:51 +00:00
or echo bg: invalid option -23 >&2
2020-02-08 08:44:39 +00:00
#CHECKERR: bg: invalid option -23
fg 3
2020-02-08 08:44:39 +00:00
#CHECKERR: fg: No suitable job: 3
bg 3
2020-02-08 08:44:39 +00:00
#CHECKERR: bg: Could not find job '3'
sleep 1 &
disown
jobs -c
2020-02-08 08:44:39 +00:00
#CHECK: Command
#CHECK: sleep
#CHECK: sleep
disown foo
2020-02-08 08:44:39 +00:00
#CHECKERR: disown: 'foo' is not a valid job specifier
disown (jobs -p)
or exit 0
2019-04-19 06:08:16 +00:00
# Verify `jobs` output within a function lists background jobs
2019-04-19 06:08:16 +00:00
# https://github.com/fish-shell/fish-shell/issues/5824
function foo
sleep 0.2 &
jobs -c
2019-04-19 06:08:16 +00:00
end
foo
# Verify we observe job exit events
sleep 1 &
set sleep_job $last_pid
function sleep_done_$sleep_job --on-job-exit $sleep_job
/bin/echo "sleep is done"
functions --erase sleep_done_$sleep_job
end
sleep 2
# Verify `jobs -l` works and returns the right status codes
# https://github.com/fish-shell/fish-shell/issues/6104
jobs --last --command; echo $status
2020-02-08 08:44:39 +00:00
#CHECK: Command
#CHECK: sleep
#CHECK: sleep is done
#CHECK: 1
sleep 0.2 &
jobs -lc; echo $status
2020-02-08 08:44:39 +00:00
#CHECK: Command
#CHECK: sleep
#CHECK: 0