dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Kitt <steve@sk2.org>
To: dash@vger.kernel.org
Cc: Stephen Kitt <steve@sk2.org>
Subject: [PATCH] Handle string-based job descriptors
Date: Fri,  3 Jun 2016 09:54:31 +0200	[thread overview]
Message-ID: <1464940471-9819-1-git-send-email-steve@sk2.org> (raw)

When looking for a job using a string descriptor, e.g.

	fg %man

the relevant loop in src/jobs.c only ever exits to the err label. With
this patch, when the end condition is reached, we check whether a job
was found, and if so, set things up to exit correctly via gotit.
Multiple matches are already caught using the test in the match block.

Signed-off-by: Stephen Kitt <steve@sk2.org>
 src/jobs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/jobs.c b/src/jobs.c
index c2c2332..37f3b41 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -715,8 +715,14 @@ check:
 	found = 0;
 	while (1) {
-		if (!jp)
-			goto err;
+		if (!jp) {
+			if (found) {
+				jp = found;
+				goto gotit;
+			} else {
+				goto err;
+			}
+		}
 		if (match(jp->ps[0].cmd, p)) {
 			if (found)
 				goto err;

             reply	other threads:[~2016-06-03  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03  7:54 Stephen Kitt [this message]
2016-06-06 14:45 ` [PATCH v2] jobs: Handle string-based job descriptors Herbert Xu
2016-06-07 14:43   ` Stephen Kitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464940471-9819-1-git-send-email-steve@sk2.org \
    --to=steve@sk2.org \
    --cc=dash@vger.kernel.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).