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@xxxxxxx> --- 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; -- 2.8.1 -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html