zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: History list fix
Date: Tue, 13 Aug 1996 18:04:01 +0200	[thread overview]
Message-ID: <199608131604.SAA22314@hydra.ifh.de> (raw)

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.


             reply	other threads:[~1996-08-13 16:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-13 16:04 Peter Stephenson [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199608131604.SAA22314@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).