jobs: return success when a job is found via --last

Closes #6104.
This commit is contained in:
David Adam 2019-09-11 13:17:23 +08:00 committed by Mahmoud Al-Qudsi
parent 737c2d156d
commit 77ef2ef6c3
4 changed files with 13 additions and 1 deletions

View file

@ -23,6 +23,7 @@
- `switch` now allows arguments that expand to nothing, like empty variables (#5677).
- The null command (:) now always exits successfully, rather than echoing last return code.
- Cursor configuration instructions for vi-mode have been added to the fish documentation.
- `jobs --last` returns 0 to indicate success when a job is found (#6104).
### Syntax changes and new commands
- Brace expansion now only takes place if the braces include a "," or a variable expansion, so things like `git reset HEAD@{0}` now work (#5869).

View file

@ -174,9 +174,10 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
for (const auto &j : parser.jobs()) {
if (j->is_visible()) {
builtin_jobs_print(j.get(), mode, !streams.out_is_redirected, streams);
return STATUS_CMD_ERROR;
return STATUS_CMD_OK;
}
}
return STATUS_CMD_ERROR;
} else {
if (w.woptind < argc) {

View file

@ -30,3 +30,9 @@ function sleep_done_$sleep_job --on-job-exit $sleep_job
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
sleep 0.2 &
jobs -lc; echo $status

View file

@ -9,3 +9,7 @@ sleep
Command
sleep
sleep is done
1
Command
sleep
0