From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id CAA02715 for ; Wed, 14 Aug 1996 02:15:40 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id MAA14379; Tue, 13 Aug 1996 12:05:29 -0400 (EDT) Resent-Date: Tue, 13 Aug 1996 12:05:29 -0400 (EDT) Message-Id: <199608131604.SAA22314@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: History list fix Date: Tue, 13 Aug 1996 18:04:01 +0200 From: Peter Stephenson Resent-Message-ID: <"r6tgX3.0.bW3.8VA4o"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1956 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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 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.