From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 95B2C6DE0931 for ; Thu, 28 Dec 2017 19:51:44 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.009 X-Spam-Level: X-Spam-Status: No, score=-0.009 tagged_above=-999 required=5 tests=[AWL=-0.009] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oLatQ4vxIGvk for ; Thu, 28 Dec 2017 19:51:40 -0800 (PST) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id 88B6F6DE0183 for ; Thu, 28 Dec 2017 19:51:36 -0800 (PST) Received: from fifthhorseman.net (ool-6c3a0662.static.optonline.net [108.58.6.98]) by che.mayfirst.org (Postfix) with ESMTPSA id 938F4F99A; Thu, 28 Dec 2017 22:51:35 -0500 (EST) Received: by fifthhorseman.net (Postfix, from userid 1000) id 8B3E520B15; Thu, 28 Dec 2017 22:45:40 -0500 (EST) From: Daniel Kahn Gillmor To: David Bremner , Notmuch Mail Subject: Re: [PATCH v4 1/3] cli: some keyword options can be supplied with no argument In-Reply-To: <87a7y9a56d.fsf@tethera.net> References: <20171219164055.20778-1-dkg@fifthhorseman.net> <20171219164055.20778-2-dkg@fifthhorseman.net> <87a7y9a56d.fsf@tethera.net> Date: Thu, 28 Dec 2017 22:45:40 -0500 Message-ID: <87h8sai4d7.fsf@fifthhorseman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Dec 2017 03:51:44 -0000 On Sat 2017-12-23 10:29:30 -0400, David Bremner wrote: > Daniel Kahn Gillmor writes: > >> >> + bool incremented = false; >> if (next == '\0' && next_arg != NULL && ! try->opt_bool) { >> next = ' '; >> value = next_arg; >> + incremented = true; >> opt_index ++; >> } > > Is incremented == true exactly when next == ' ' ? It might be nice to > make that more explicit by setting one based on the other. You could > also use (next == ' ') as your test condition, but I understand that > might not be that obvious to read. yes, i was aiming for readability. I'm assuming that the compiler can optimize this as needed. > The thing I'm most nervous about here is the interaction between this > new code and the relatively recent code that permits ' ' as a > seperator. Would you mind adding one or more tests for that case? For > example, that I checked that > > ./notmuch show --format=json --decrypt true $id > > continues to work, and that's great, but it seems like something to > check on the argument parsing level, i.e > > --keyword␣non-default-value > > (pardon my unicode) I'm fine with that, and with your proposed revision of this patch that includes the amended test. thanks for pushing it forward. --dkg