zsh-users
 help / color / mirror / Atom feed
* Repeating last command from *local* history
@ 2021-02-11 16:37 Andreas Kusalananda Kähäri
  2021-02-11 20:47 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Kusalananda Kähäri @ 2021-02-11 16:37 UTC (permalink / raw)
  To: zsh-users

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.


Regards,

-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Repeating last command from *local* history
  2021-02-11 16:37 Repeating last command from *local* history Andreas Kusalananda Kähäri
@ 2021-02-11 20:47 ` Peter Stephenson
  2021-02-28 13:25   ` Andreas Kusalananda Kähäri
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2021-02-11 20:47 UTC (permalink / raw)
  To: zsh-users

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)



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Repeating last command from *local* history
  2021-02-11 20:47 ` Peter Stephenson
@ 2021-02-28 13:25   ` Andreas Kusalananda Kähäri
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Kusalananda Kähäri @ 2021-02-28 13:25 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

On Thu, Feb 11, 2021 at 08:47:46PM +0000, Peter Stephenson wrote:
> 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
> 

The patch seems to have made it into the zsh Git repository.  I've
re-built the shell from there and "r -L" now seems to work the way I was
initially expecting it to work.  Thanks for this!


Regards,

-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-28 13:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 16:37 Repeating last command from *local* history Andreas Kusalananda Kähäri
2021-02-11 20:47 ` Peter Stephenson
2021-02-28 13:25   ` Andreas Kusalananda Kähäri

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ http://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git