From patchwork Tue Feb 7 19:33:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13132066 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 C335BC636D3 for ; Tue, 7 Feb 2023 19:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbjBGTdz (ORCPT ); Tue, 7 Feb 2023 14:33:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231772AbjBGTdr (ORCPT ); Tue, 7 Feb 2023 14:33:47 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 41DA03CE0C for ; Tue, 7 Feb 2023 11:33:29 -0800 (PST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id C232411C4; Tue, 7 Feb 2023 20:33:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1675798406; bh=+zPNgPih9bH/NvfdpusETLSd0TrgWTt+UCzMQH6RvzA=; h=Date:From:To:Subject:References:In-Reply-To:From; b=QPXoyeHbl3ZT0pyC52AB/BOPXYxgIk3iJmuffQms2HSiN0u3Z6jHkX5ia2eaSil9J b7NmqKL9fopTlek/o7FOyv1aUVhKISaXOKLRf/2HQP177D4wQ7UeHstVWmsE5Z0dMY yI8tvc/B59MkAP/GtIVEBqVEi19aw64NxgvDYC4gpcv+7xNqBbDJJ8QMdOqsd4VRqI s7SAN/8Dn6wwzXt94pDNVVPmxApTdEOcEsokqaNUjHBbEFcMxDe4uq85KrroI8RM4F GsCJxGIr10elRAWGbfbaRuM+OTDzHhlu6ZPJpHjwEANINJExO8Fx7UP+PJCVhcQ6Mj rzUVDw3tZZHJA== Date: Tue, 7 Feb 2023 20:33:25 +0100 From: =?utf-8?b?0L3QsNCx?= To: Harald van Dijk , dash@vger.kernel.org Subject: [PATCH 1/6] fc -s: refuse multiple events instead of ignoring Message-ID: <96c003b30fc95cdf5aed3162901abaa9b89430e2.1675798292.git.nabijaczleweli@nabijaczleweli.xyz> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20220429 Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org The POSIX SYNOPSIS (and our manual which steals it verbatim) says: fc -s [old=new] [first] and, indeed, we only use the first non-= argument instead of enforcing the usage, which is confusing. bash: 2025 ls 2026 id $ fc -s ls=who 2025 2026 who nabijaczleweli pts/2 2023-02-07 17:36 (192.168.1.109) nabijaczleweli pts/3 2023-02-07 17:38 (192.168.1.109) nabijaczleweli pts/4 2023-02-07 16:58 (192.168.1.109) nabijaczleweli pts/5 2023-02-07 17:45 (192.168.1.109) ksh93: 240 id 241 ls $ fc -s ls=who 241 240 ksh: hist: -e - requires single argument yash: 2 ls 3 id $ fc -s ls=who 2 3 fc: too many operands are specified zsh: 2 id 3 ls tarta% fc -s ls=who 3 2 fc: bad option: -s dash (before): 1 ls 2 id $ fc -s ls=who 1 2 who nabijaczleweli pts/2 2023-02-07 17:36 (192.168.1.109) nabijaczleweli pts/3 2023-02-07 17:38 (192.168.1.109) nabijaczleweli pts/4 2023-02-07 16:58 (192.168.1.109) nabijaczleweli pts/5 2023-02-07 17:45 (192.168.1.109) dash (after): 1 ls 2 id $ fc -s ls=who 1 2 src/dash: 3: fc: -s takes one history argument Adapted-from: NetBSD src bin/sh/histedit.c rev 1.38 by aymeric@ --- Here's a quick few that fix my report and a couple of the ones you list at the end of that thread. src/histedit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/histedit.c b/src/histedit.c index f5c90ab..fc87283 100644 --- a/src/histedit.c +++ b/src/histedit.c @@ -296,6 +296,13 @@ histcmd(int argc, char **argv) *repl++ = '\0'; argc--, argv++; } + + /* + * If -s is specified, accept only one operand + */ + if (sflg && argc >= 2) + sh_error("too many args"); + /* * determine [first] and [last] */