From patchwork Fri Jun 3 07:54:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Kitt X-Patchwork-Id: 9152035 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6DE5A60751 for ; Fri, 3 Jun 2016 07:54:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F0E226907 for ; Fri, 3 Jun 2016 07:54:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53D43281F9; Fri, 3 Jun 2016 07:54:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7604026907 for ; Fri, 3 Jun 2016 07:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751538AbcFCHyk (ORCPT ); Fri, 3 Jun 2016 03:54:40 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:31144 "EHLO smtp5-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751082AbcFCHyj (ORCPT ); Fri, 3 Jun 2016 03:54:39 -0400 Received: from heffalump.sk2.org (unknown [88.186.243.14]) by smtp5-g21.free.fr (Postfix) with ESMTPS id 307BD5FFB9 for ; Fri, 3 Jun 2016 09:57:13 +0200 (CEST) Received: from steve by heffalump.sk2.org with local (Exim 4.87) (envelope-from ) id 1b8jwC-0002Zk-NA; Fri, 03 Jun 2016 09:54:36 +0200 From: Stephen Kitt To: dash@vger.kernel.org Cc: Stephen Kitt Subject: [PATCH] Handle string-based job descriptors Date: Fri, 3 Jun 2016 09:54:31 +0200 Message-Id: <1464940471-9819-1-git-send-email-steve@sk2.org> X-Mailer: git-send-email 2.8.1 Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;