Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wait command #4498

Closed
wants to merge 1 commit into from
Closed

Conversation

s417-lama
Copy link
Contributor

Description

We (@tasq0 and I) implemented wait command.

The implementation is almost following POSIX. As discussed in issue #1422, we can't retain the exit status of background jobs, but we thought it's not a critical problem. If we want to know the failure of background jobs, there are another ways to do it. Shell needs wait command.

The functions we implemented

Wait for all background jobs

With no options specified, wait for all background jobs finishing.

For example:

$ sleep 5 &; sleep 10 &; sleep 7 &
$ wait
Job 1, 'sleep 5 &' has ended
Job 3, 'sleep 7 &' has ended
Job 2, 'sleep 10 &' has ended
$

Wait for specified jobs

With job ids or process ids specified, wait for only specified jobs finishing.

For example:

$ sleep 5 &; sleep 10 &; sleep 7 &
$ wait %1 %3
Job 1, 'sleep 5 &' has ended
Job 3, 'sleep 7 &' has ended
$
Job 2, 'sleep 10 &' has ended

The wait command returns before job 2 (sleep 10 &) finishes.

Wait for any background jobs

With -n option given, wait for any background jobs finishing.

For example:

$ sleep 5 &; sleep 10 &; sleep 7 &
$ wait -n
Job 1, 'sleep 5 &' has ended
$
Job 3, 'sleep 7 &' has ended
Job 2, 'sleep 10 &' has ended

The wait command returns immediately when job 1 (sleep 5 &) finishes.

Acknowledgment

I would like to express my gratitude to @tasq0 who also greatly contributed to this PR.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added
  • User-visible changes noted in CHANGELOG.md

@ridiculousfish
Copy link
Member

Well this looks awesome! I'll review!

@zanchey zanchey added this to the fish-3.0 milestone Oct 31, 2017
@ridiculousfish
Copy link
Member

Ugh, I'm sorry this sat so long! Merged as c7a682e, thanks!

@ridiculousfish
Copy link
Member

Added to changelog as 51d34e1

@ridiculousfish
Copy link
Member

Docs added as 1014995

@zanchey zanchey added the release notes Something that is or should be mentioned in the release notes label Nov 17, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement release notes Something that is or should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants