Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Repeating last command from *local* history
- X-seq: zsh-users 26509
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Repeating last command from *local* history
- Date: Thu, 11 Feb 2021 20:47:46 +0000
- Archived-at: <https://zsh.org/users/26509>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-02/27299937c9c060b1a8ed1acbce6cda5c72d63a64.camel%40ntlworld.com>
- In-reply-to: <20210211163728.GA8608@box.prefix.duckdns.org>
- List-id: <zsh-users.zsh.org>
- References: <20210211163728.GA8608@box.prefix.duckdns.org>
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)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author