From: Wayne Davison <wayned@users.sourceforge.net>
To: Zsh Workers <zsh-workers@sunsite.dk>
Subject: Changing "0" as a history-line reference
Date: Mon, 13 May 2002 15:31:38 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.44.0205131524280.28310-100000@phong.blorf.net> (raw)
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---
next reply other threads:[~2002-05-13 22:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-13 22:31 Wayne Davison [this message]
2002-05-14 15:44 ` 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=Pine.LNX.4.44.0205131524280.28310-100000@phong.blorf.net \
--to=wayned@users.sourceforge.net \
--cc=zsh-workers@sunsite.dk \
/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).