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
base: master
from

Conversation

Projects
None yet
3 participants
@s417-lama
Copy link
Contributor

s417-lama commented Oct 22, 2017

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

This comment has been minimized.

Copy link
Member

ridiculousfish commented Oct 22, 2017

Well this looks awesome! I'll review!

@zanchey zanchey requested a review from ridiculousfish Oct 31, 2017

@zanchey zanchey added the enhancement label Oct 31, 2017

@zanchey zanchey added this to the fish-3.0 milestone Oct 31, 2017

@ridiculousfish

This comment has been minimized.

Copy link
Member

ridiculousfish commented Nov 16, 2017

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

@ridiculousfish

This comment has been minimized.

Copy link
Member

ridiculousfish commented Nov 16, 2017

Added to changelog as 51d34e1

@ridiculousfish

This comment has been minimized.

Copy link
Member

ridiculousfish commented Nov 16, 2017

Docs added as 1014995

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment