zsh-workers
 help / color / mirror / code / Atom feed
* Changing "0" as a history-line reference
@ 2002-05-13 22:31 Wayne Davison
  2002-05-14 15:44 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Wayne Davison @ 2002-05-13 22:31 UTC (permalink / raw)
  To: Zsh Workers

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---


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

* Re: Changing "0" as a history-line reference
  2002-05-13 22:31 Changing "0" as a history-line reference Wayne Davison
@ 2002-05-14 15:44 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2002-05-14 15:44 UTC (permalink / raw)
  To: Wayne Davison, Zsh Workers

On May 13,  3:31pm, Wayne Davison wrote:
}
} 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?

If not for the fact that it's the inverse of all other uses of zero-based
indexing in the shell, I'd say it was a good idea.  As it is, though, I'm
not sure.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2002-05-14 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-13 22:31 Changing "0" as a history-line reference Wayne Davison
2002-05-14 15:44 ` Bart Schaefer

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).