From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21880 invoked from network); 11 Feb 2021 20:48:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2021 20:48:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1613076498; b=AyNo9ikPWFQM5zX+lSYOsil9uO50VvqBigRijqWQyc5jrfzlz5g+HGU2WT0GLSLkxpyKhLhNU8 mlfqtBKEfBCLHiHG/oUfMEZIxLdhx0da6ES+eQfXorXyKAioXmfGHqPrYGVV9kziy2LJDdyvMy p2sY/yfw6fR/DHolkTK+vpI5ntTBNcIlVHv17+tnHXCmD7o+MFHm4Ni+bZp1ToK5FwR2yMy4Ef eivxy2n4lJDwGbZGiOsA7IFhh9nN5xw8596xeL4DMgObc3y6v3ITH2B+G0nbmeeu+x3ayFMyOz VE4516ibkKdyGPGjHqKCgwuF9EdjRD45rCIi8TtQZWWR1A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (know-smtprelay-omc-1.server.virginmedia.net) smtp.remote-ip=80.0.253.65; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1613076498; bh=5YkyP3bAdxCkXwNnZ+WWaKaFJ/QHMpBdJw59NPk7UlU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Content-Type: References:In-Reply-To:Date:To:From:Subject:Message-ID:DKIM-Signature: DKIM-Signature; b=AhPqbSSdF4y4KD/jinBi/9A2oQAMMoVxeSD1ZfkLCqkfS/F7Q5HqZe1/e4+rkwBLU34p8UKl1H ha87RVgVj710HOLDsQk9GSde+ojMNI22QWCwXrl92K3KGsGAq9LSM4tt7CbAzsiQIIvgQEg2F5 vWdX1/yaOmm5j9X/Ou9GhWxzBnx3U8rnTHM4bdEF1LyHALnHFIZ5dZ/YN3TBkkQpg8/VKJZuSW 46jXJUCJFZNaPgfUIMVJZyjunVswqr31NT8d7NyB477OMJ2Eko9fSm4e960/tI4gOtaOUCfjqi QQ5gGGYFN9r2be4RMJNtL6Q7O9+EXuz84sN6neMslI0Z5g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Mime-Version:Content-Type:References:In-Reply-To:Date:To:From:Subject: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=bZAp2ZzwoGPmlKNchw/be5Gmb9nonRlHgGJguO6C3WY=; b=jdsgDkT0SiDZwSRbv8zUVAPewL PetejhPjFJc2HU/zzuCNoQiDIBAB5qqDPkr8dDADCqv3vKV+zKH2TTqQXMdZmdobcXrOOJOel1rV9 CZOw3xmBUYwAk7BpsOTC2NIsNhsbhhFezJNbWOUQ7r1zfswedCF89OE13fp3jvge5iw89P+hiY3mW FhX4GYuGPd8LG9X+o+XTDnm3qYi2Y8XnId2lu+OXp8qPihPyrb3xhsBluDnJwExNYG1bC/TOSH3uV tCDB8fLn5m6Tf6oP4Wj518Qcc1lY9juKn9f5IPLq5USxCDaIYCNrxbRlYyLROtZSmhbDxd5bblYNY OQIGfe5g==; Received: from authenticated user by zero.zsh.org with local id 1lAIsq-000DFb-UU; Thu, 11 Feb 2021 20:48:16 +0000 Authentication-Results: zsh.org; iprev=pass (know-smtprelay-omc-1.server.virginmedia.net) smtp.remote-ip=80.0.253.65; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from know-smtprelay-omc-1.server.virginmedia.net ([80.0.253.65]:58409) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lAIsN-000Ct7-7T; Thu, 11 Feb 2021 20:47:48 +0000 Received: from pws-Zeus ([82.20.19.64]) by cmsmtp with ESMTPA id AIsMlxiZQnHyIAIsMl4K4F; Thu, 11 Feb 2021 20:47:46 +0000 X-Originating-IP: [82.20.19.64] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=MMlOZvRl c=1 sm=1 tr=0 a=FYxK54AnRTbDA0SLc6W5Eg==:117 a=FYxK54AnRTbDA0SLc6W5Eg==:17 a=IkcTkHD0fZMA:10 a=CrxVmc8gnfb_pDezgKQA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1613076466; bh=bZAp2ZzwoGPmlKNchw/be5Gmb9nonRlHgGJguO6C3WY=; h=Subject:From:To:Date:In-Reply-To:References; b=aCt4WAH5XX0lLced8pfQY7C7KFILKvoMGkNGw7Q3ceN5jf/kwRW2DK8On0Nl8YoWj EspuPZxQn/4uqGmBS2NkoPsUFlFE1Lk/G3PrteKShZeX1k4cAbo5EgjFFX9sKJqF0C MursDtr1yZP4omTmRyz7NFpZUivB0gZAoQ/znhrGSCV7jh0KYZ7Kh8WqhDaprVcIr4 2w/5VTURfGml8k0aT7syDG9UT5Rbp/lFXrsL2tem7CkTbgUcmJRf9I55YawA8uUjY6 HV7GvfKJ/2GLijptohNBv5Di7fcK2GZSZMwskilAk7gg5aY9MMmMrDt9Qyq+D0GfVs jTis/34JST7qg== Message-ID: <27299937c9c060b1a8ed1acbce6cda5c72d63a64.camel@ntlworld.com> Subject: Re: Repeating last command from *local* history From: Peter Stephenson To: zsh-users@zsh.org Date: Thu, 11 Feb 2021 20:47:46 +0000 In-Reply-To: <20210211163728.GA8608@box.prefix.duckdns.org> References: <20210211163728.GA8608@box.prefix.duckdns.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfN4qtg4/KZ053USSl1DhHCHVn6X6EIoVmZOrJJTrv07jRSOXr1zuwcA/9EmpFxMBJQrfXIb/wuS3KiSX8MEn+PD8ZIJgeceaC8p0ysBk0MQ83B/fT8SE TgNWdaC3Y7fEi/MnnAnjn9uGb7Y7KOxMCP8w4atPJRwGDbHDtx9KJ/XW X-Seq: 26509 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On Thu, 2021-02-11 at 17:37 +0100, Andreas Kusalananda Kähäri wrote: > I'm using zsh 5.8 on OpenBSD 6.8, and I set the SHARE_HISTORY and > EXTENDED_HISTORY shell options. > > I would like to repeat the last command from the command line history > of the current shell session, without accidentally executing a recent > command from some other shell session that I'm using in another > terminal. > > Using "r -L" works, but only if the most recent command in the shared > history is a command from the current shell session. If it isn't, the > shell responds with "fc: no matching events found". > > This *feels* like a bug. Yes, it's a typical "computer says no" bug. I thin this one's easy, although it's possible there are more implications here than I'm picking up... pws diff --git a/Src/builtin.c b/Src/builtin.c index 35a0fb2db..8d7fd23d6 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -1599,8 +1599,9 @@ bin_fc(char *nam, char **argv, Options ops, int func) * command line to avoid giving the user a nasty turn * if some helpful soul ran "print -s 'rm -rf /'". */ - first = OPT_ISSET(ops,'l')? addhistnum(curhist,-16,0) - : addhistnum(curline.histnum,-1,0); + int xflags = OPT_ISSET(ops,'L') ? HIST_FOREIGN : 0; + first = OPT_ISSET(ops,'l')? addhistnum(curhist,-16,xflags) + : addhistnum(curline.histnum,-1,xflags); if (first < 1) first = 1; if (last < first)