From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27561 invoked from network); 13 May 2002 22:31:52 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 13 May 2002 22:31:52 -0000 Received: (qmail 5180 invoked by alias); 13 May 2002 22:31:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17144 Received: (qmail 5169 invoked from network); 13 May 2002 22:31:43 -0000 Date: Mon, 13 May 2002 15:31:38 -0700 (PDT) From: Wayne Davison To: Zsh Workers Subject: Changing "0" as a history-line reference Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I'm curious what people think about making a "0" in a history-line reference man the last line in the history instead of the first? Currently "0" is synonymous with "1". Since -1 is "last minus one", I was thinking that it might make more sense to have "0" mean "last". For instance, "history -99 0" would output the last 100 lines of the history, including the very last command (which might be a script that actually called the history command). The user could currently use something like "999999" instead of "0", so this is not really that big of a deal, but I like it. Here's the simple patch. ..wayne.. ---8<------8<------8<------8<---cut here--->8------>8------>8------>8--- Index: Doc/Zsh/builtins.yo --- Doc/Zsh/builtins.yo 10 May 2002 09:52:25 -0000 1.45 +++ Doc/Zsh/builtins.yo 13 May 2002 22:23:54 -0000 @@ -369,7 +369,7 @@ Select a range of commands from var(first) to var(last) from the history list. The arguments var(first) and var(last) may be specified as a -number or as a string. A negative number is used as an offset +number or as a string. A non-positive number is used as an offset to the current history event number. A string specifies the most recent event beginning with the given string. All substitutions var(old)tt(=)var(new), if any, are then performed Index: Src/builtin.c --- Src/builtin.c 24 Mar 2002 07:56:42 -0000 1.73 +++ Src/builtin.c 13 May 2002 22:23:55 -0000 @@ -1389,10 +1389,10 @@ { int cmd; - /* First try to match a history number. Negative * + /* First try to match a history number. Non-positive * * numbers indicate reversed numbering. */ if ((cmd = atoi(s)) != 0 || *s == '0') { - if (cmd < 0) + if (cmd <= 0) cmd = addhistnum(curline.histnum,cmd,HIST_FOREIGN); if (cmd < 0) cmd = 0; ---8<------8<------8<------8<---cut here--->8------>8------>8------>8---