Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug(?) in builtin r
- X-seq: zsh-workers 25338
- From: Peter Stephenson <pws@xxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: Re: Bug(?) in builtin r
- Date: Fri, 25 Jul 2008 09:52:52 +0100
- In-reply-to: <20080724181636.5dd92ddd@news01>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
- References: <2d460de70807240752ge3b0a5qbfa640585c101c35@xxxxxxxxxxxxxx> <20080724181636.5dd92ddd@news01>
On Thu, 24 Jul 2008 18:16:36 +0100
Peter Stephenson <pws@xxxxxxx> wrote:
> Hmm... repeating the current line and doing something else with it (rather
> than just repeating it) is potentially useful. However, in zsh this is
> handled recursively, so you quickly get into problems on the stack.
...and also you end up with huge numbers of temporary files that stack up
unless the whole sequence exits cleanly, which is possibly worse in the
long run.
> This disallows the specific case that the range includes the current
> history entry and nothing before it, and there's no editor. Otherwise it
> either truncates the history so that the current line isn't included, or if
> you've specified an editor it lets you edit the current line, too, if you
> really want. It's not clear that last bit is actually useful and it might
> be better consistently to ignore the current history line here.
That's what I'll do. Editing the line with an external editor isn't all
that common and if you do it's likely to be better to reduce surprises
rather than provide the almost certainly unnecessary current history line.
I missed an unlink(fil) last time.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.197
diff -u -r1.197 builtin.c
--- Src/builtin.c 17 Jul 2008 11:27:57 -0000 1.197
+++ Src/builtin.c 25 Jul 2008 08:48:24 -0000
@@ -1446,6 +1446,20 @@
unqueue_signals();
zwarnnam("fc", "can't open temp file: %e", errno);
} else {
+ /*
+ * Nasty behaviour results if we use the current history
+ * line here. Treat it as if it doesn't exist, unless
+ * that gives us an empty range.
+ */
+ if (last >= curhist) {
+ last = curhist - 1;
+ if (first > last) {
+ unqueue_signals();
+ zwarnnam("fc", "invalid use of current history line");
+ unlink(fil);
+ return 1;
+ }
+ }
ops->ind['n'] = 1; /* No line numbers here. */
if (!fclist(out, ops, first, last, asgf, pprog)) {
char *editor;
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author