zsh-workers
 help / color / mirror / code / Atom feed
* History list fix
@ 1996-08-13 16:04 Peter Stephenson
  1996-08-13 23:08 ` Zoltan Hidvegi
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 1996-08-13 16:04 UTC (permalink / raw)
  To: Zsh hackers list

This fixes the off-by-one error when trying to list just the last
history entry (you can't, neither with nor without HISTNOSTORE set).

At least, it seems to fix it: it's a bit confusing when you don't have
HISTNOSTORE set but you do have HISTIGNOREDUPS set, since if the
previous command is the same as the current history command you don't
see it.  However, I suppose that's logical: with my recent
HISTIGNOREDUPS command it's really always the last command which is in
the history list, which is still the current comand, and `history'
never shows the current command.  (People repeating identical history
commands only tend to be testing the history code anyway.)

This error by tradition reappears whenever anybody makes any change to
the fc code.  I've tried to reduce the likelihood of a recrudescence
by removing the two confusing possibilities, i.e. either the current
history entry is already deleted or is about to be.  With this patch
curhist is always still the fc/history command itself.  Otherwise,
there are unpleasant dependencies on HISTNOSTORE.

By the way, there's another fix of mine for a traditional bug, namely
the bogus `permission denied' error when trying to execute a
non-existent programme with an unreadable directory somewhere in the
path, which seems to have gone missing.

*** Src/builtin.c.fc	Mon Aug  5 14:38:39 1996
--- Src/builtin.c	Tue Aug 13 17:53:59 1996
***************
*** 2433,2444 ****
      }
      delayrem = 0;
      if (!(ops['l'] && unset(HISTNOSTORE)) &&
! 	!(ops['R'] || ops['W'] || ops['A'])) {
! 	if (ops['l'])
! 	    remhist();
! 	else
! 	    delayrem = 1;
!     }
      if (ops['R']) {
  	/* read history from a file */
  	readhistfile(*argv ? *argv : getsparam("HISTFILE"), 1);
--- 2433,2440 ----
      }
      delayrem = 0;
      if (!(ops['l'] && unset(HISTNOSTORE)) &&
! 	!(ops['R'] || ops['W'] || ops['A']))
! 	delayrem = 1;
      if (ops['R']) {
  	/* read history from a file */
  	readhistfile(*argv ? *argv : getsparam("HISTFILE"), 1);
***************
*** 2474,2488 ****
      if (*argv) {
  	minflag = **argv == '-';
  	first = fcgetcomm(*argv);
! 	if (first == -1)
  	    return 1;
  	argv++;
      }
      /* interpret and check second history line specifier */
      if (*argv) {
  	last = fcgetcomm(*argv);
! 	if (last == -1)
  	    return 1;
  	argv++;
      }
      /* There is a maximum of two history specifiers.  At least, there *
--- 2470,2490 ----
      if (*argv) {
  	minflag = **argv == '-';
  	first = fcgetcomm(*argv);
! 	if (first == -1) {
! 	    if (delayrem)
! 		remhist();
  	    return 1;
+ 	}
  	argv++;
      }
      /* interpret and check second history line specifier */
      if (*argv) {
  	last = fcgetcomm(*argv);
! 	if (last == -1) {
! 	    if (delayrem)
! 		remhist();
  	    return 1;
+ 	}
  	argv++;
      }
      /* There is a maximum of two history specifiers.  At least, there *
***************
*** 2489,2494 ****
--- 2491,2498 ----
       * will be as long as the history list is one-dimensional.        */
      if (*argv) {
  	zwarnnam("fc", "too many arguments", NULL, 0);
+ 	if (delayrem)
+ 	    remhist();
  	return 1;
      }
      /* default values of first and last, and range checking */
***************
*** 2495,2501 ****
      if (first == -1)
  	first = (ops['l']) ? curhist - 16 : curhist - 1;
      if (last == -1)
! 	last = (ops['l']) ? curhist : first;
      if (first < firsthist())
  	first = firsthist();
      if (last == -1)
--- 2499,2505 ----
      if (first == -1)
  	first = (ops['l']) ? curhist - 16 : curhist - 1;
      if (last == -1)
! 	last = (ops['l']) ? curhist - 1 : first;
      if (first < firsthist())
  	first = firsthist();
      if (last == -1)

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Old messages
@ 1996-08-14 15:55 whukriede
  0 siblings, 0 replies; 7+ messages in thread
From: whukriede @ 1996-08-14 15:55 UTC (permalink / raw)
  To: zsh-workers


> There used to be a nice www archive wich is also mentioned in the FAQ on
> http://www-stud.enst.fr/~tardieu/mailarchive/zsh-list/index.html but it
> does not work recently.

I mailed him on August, 3, until now, there was no reply. I'd suggest to
remove this pointer from the Faq.

Greetings, Wolfgang.


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

end of thread, other threads:[~1996-08-14 20:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-13 16:04 History list fix Peter Stephenson
1996-08-13 23:08 ` Zoltan Hidvegi
1996-08-14  7:31   ` Old messages Geoff Wing
1996-08-14 13:03     ` Zoltan Hidvegi
1996-08-14 19:05       ` Zefram
1996-08-14 20:24         ` Bart Schaefer
1996-08-14 15:55 whukriede

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).