From patchwork Tue Dec 13 21:13:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13072426 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03D94C4332F for ; Tue, 13 Dec 2022 21:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235574AbiLMVNk (ORCPT ); Tue, 13 Dec 2022 16:13:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235551AbiLMVNk (ORCPT ); Tue, 13 Dec 2022 16:13:40 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9840B13E12 for ; Tue, 13 Dec 2022 13:13:37 -0800 (PST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id CC8C913AE for ; Tue, 13 Dec 2022 22:13:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1670966014; bh=5lKuos6I/pVpfCRluZjl/jZOs5ePv5uNU0TPYnQ7n8M=; h=Date:From:To:Subject:From; b=SvKgfluXxeQv72vQh8iNq6jXdzmx1vbZIXSVDAqdXP2cJaNy0gwAEL1sDy1g6YfX1 lEkhDg8uOT1zUaXJxFL+HUds0jSWTBrHXIXYRFB2MLbAhs/FF6eXBXTo+10tWVEbK1 9SPJ/HZ7EYug4SsoC58RYEl7QCFrT4dmFGbmK8aB2R5LgWzr2RF6XYD2rXeUbbKfdm y03CR4Kth+l5hRLeHNPdTd8sxTFKj8SQhTbHbmWaI702C0PJNOu2RZZ5panisXXob+ PRRIHuaZdPczyW2BDyTT6pTIqKaOT8/1gJP1lbUDVYZuowaNmHlR+dah/qF/987lGL oslIyvTBiEC2A== Date: Tue, 13 Dec 2022 22:13:33 +0100 From: =?utf-8?b?0L3QsNCx?= To: dash@vger.kernel.org Subject: [PATCH 1/2] exec: type: ignore first --, per POSIX Message-ID: MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20220429 Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org Issue 7, XCU, type, OPTIONS reads "None.", and type isn't a special built-in listed in sexion 2.14 ‒ this means that XCU, 1. Introduction, 1.4 Utility Description Defaults, OPTIONS, Default Behavior applies: Default Behavior: When this section is listed as "None.", it means that the implementation need not support any options. Standard utilities that do not accept options, but that do accept operands, shall recognize "--" as a first argument to be discarded. Test with: type -- ls -- Correct output lists ls=/bin/ls, then --=ENOENT Wrong output lists --=ENOENT, ls=/bin/ls, --=ENOENT Fixes: https://bugs.debian.org/870317 --- src/exec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/exec.c b/src/exec.c index 87354d4..d61881d 100644 --- a/src/exec.c +++ b/src/exec.c @@ -760,11 +760,11 @@ unsetfunc(const char *name) int typecmd(int argc, char **argv) { - int i; int err = 0; - for (i = 1; i < argc; i++) { - err |= describe_command(out1, argv[i], NULL, 1); + nextopt(nullstr); + while (*argptr) { + err |= describe_command(out1, *argptr++, NULL, 1); } return err; }