From patchwork Mon Jul 13 06:06:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 6774351 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-dash@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B0EC0C05AC for ; Mon, 13 Jul 2015 06:07:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D327120489 for ; Mon, 13 Jul 2015 06:07:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 533DB205F3 for ; Mon, 13 Jul 2015 06:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751469AbbGMGHn (ORCPT ); Mon, 13 Jul 2015 02:07:43 -0400 Received: from helcar.hengli.com.au ([209.40.204.226]:48223 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbbGMGHn (ORCPT ); Mon, 13 Jul 2015 02:07:43 -0400 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by norbury.hengli.com.au with esmtp (Exim 4.80 #3 (Debian)) id 1ZEWtc-0002sF-LH; Mon, 13 Jul 2015 16:07:20 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.80) (envelope-from ) id 1ZEWsv-00027C-G3; Mon, 13 Jul 2015 14:06:37 +0800 Date: Mon, 13 Jul 2015 14:06:35 +0800 From: Herbert Xu To: Martijn Dekker Cc: dash@vger.kernel.org Subject: Re: [BUG] test: -gt: unexpected operator Message-ID: <20150713060635.GA8106@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <55A2F88A.4090908@inlv.org> Organization: Core X-Newsgroups: apana.lists.os.linux.dash User-Agent: Mutt/1.5.21 (2010-09-15) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,FAKE_REPLY_C, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Martijn Dekker wrote: > I found a bug in dash that affects checking the exit status of '[' or > 'test' for failure. > > After feeding an illegal number to 'test -t', 'test' will not accept any > operator (or at least not -gt or -lt) for the next invocation. > > Confirmed in dash 0.5.7, 0.5.8 and current git version. Thanks for the report. Does this patch help? ---8<--- Subject: builtin: Reset t_wp_op in testcmd The global variable t_wp_op needs to be reset every time testcmd is called or it may cause incorrect parsing of the arguments. Reported-by: Martijn Dekker Signed-off-by: Herbert Xu diff --git a/src/bltin/test.c b/src/bltin/test.c index bab9a1f..58c05fe 100644 --- a/src/bltin/test.c +++ b/src/bltin/test.c @@ -193,6 +193,8 @@ testcmd(int argc, char **argv) argv[argc] = NULL; } + t_wp_op = NULL; + recheck: argv++; argc--;