From patchwork Mon Feb 25 04:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10828223 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-2.web.codeaurora.org (Postfix) with ESMTP id EBB4C17E6 for ; Mon, 25 Feb 2019 04:49:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D60842A8B9 for ; Mon, 25 Feb 2019 04:49:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C85922A825; Mon, 25 Feb 2019 04:49:26 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 37FCA2A5DD for ; Mon, 25 Feb 2019 04:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727054AbfBYEtY (ORCPT ); Sun, 24 Feb 2019 23:49:24 -0500 Received: from orcrist.hmeau.com ([104.223.48.154]:44456 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbfBYEtY (ORCPT ); Sun, 24 Feb 2019 23:49:24 -0500 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1gy8Cg-0008M2-Cx; Mon, 25 Feb 2019 12:49:22 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1gy8Ce-0002ha-Qx; Mon, 25 Feb 2019 12:49:20 +0800 Date: Mon, 25 Feb 2019 12:49:20 +0800 From: Herbert Xu To: Olivier Duclos Cc: dash@vger.kernel.org Subject: [PATCH] options: Do not set commandname in procargs Message-ID: <20190225044920.k2klmeddvn2ybc3b@gondor.apana.org.au> References: <1548691104.3758682.1645313288.2864B6B8@webmail.messagingengine.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1548691104.3758682.1645313288.2864B6B8@webmail.messagingengine.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jan 28, 2019 at 03:58:24PM +0000, Olivier Duclos wrote: > Hi, > > This is a small cosmetic patch which fixes something that annoyed me for a long time: the repetition of the script name in error messages. > > Example: > > $ cat test.sh > #!/bin/sh > echo ${x:?} > > $ dash test.sh > /home/odc/test.sh: 2: /home/odc/test.sh: x: parameter not set or null > > With the patch: > > $ dash test.sh > /home/odc/test.sh: 2: x: parameter not set or null > > This is the same behavior as bash. Thanks for the report! How about this patch? ---8<--- We set commandname in procargs when we don't have to. This results in a duplicated output of arg0 when an error occurs. Reported-by: Olivier Duclos Signed-off-by: Herbert Xu diff --git a/src/options.c b/src/options.c index 6f381e6..a46c23b 100644 --- a/src/options.c +++ b/src/options.c @@ -159,7 +159,6 @@ procargs(int argc, char **argv) setinputfile(*xargv, 0); setarg0: arg0 = *xargv++; - commandname = arg0; } shellparam.p = xargv;