klibc-bot for Stephen Kitt
2020-Mar-28 21:48 UTC
[klibc] [klibc:update-dash] dash: jobs: Handle string-based job descriptors
Commit-ID: 8115b5d06f75ea543d01355384cf5556aa388481 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=8115b5d06f75ea543d01355384cf5556aa388481 Author: Stephen Kitt <steve at sk2.org> AuthorDate: Mon, 6 Jun 2016 22:45:27 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: jobs: Handle string-based job descriptors [ dash commit 203e8395faa9135956e3b2a2b749b6dd96a7e988 ] 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 at sk2.org> Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/jobs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c index 49c14441..c1f9688f 100644 --- a/usr/dash/jobs.c +++ b/usr/dash/jobs.c @@ -713,9 +713,7 @@ check: } found = 0; - while (1) { - if (!jp) - goto err; + while (jp) { if (match(jp->ps[0].cmd, p)) { if (found) goto err; @@ -725,6 +723,10 @@ check: jp = jp->prev_job; } + if (!found) + goto err; + jp = found; + gotit: #if JOBS err_msg = "job %s not created under job control";