Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: prexec never gets empty string?
- X-seq: zsh-workers 34565
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: prexec never gets empty string?
- Date: Tue, 17 Feb 2015 09:09:51 -0800
- In-reply-to: <CANOe-=7Oa8pT4SSVwnpKsNrKbCFiX_x=abS1HVBcqzmt9cg3hw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CADS3xe8na+zBiEMT1qp+pjLXtDxzvRmC7QVjCt5VXSUu_1jbmA@mail.gmail.com> <CAHYJk3RKv8bZUy-DS3-QWZ6ykRRZejrF0Wwpwa=wdA1-1HCNZw@mail.gmail.com> <CANOe-=7ti2p7uUAAtD309i1BkfmUwPtK+3K0eunJJkmkEJnpGQ@mail.gmail.com> <20150214213757.010b0c82@ntlworld.com> <CANOe-=7Oa8pT4SSVwnpKsNrKbCFiX_x=abS1HVBcqzmt9cg3hw@mail.gmail.com>
On Feb 16, 9:11am, Derek Gleim wrote:
}
} As an aside, I'd still like to be able to get the prompt expansion `%!` to
} always show the number to be assigned to the next command...
}
} % PROMPT='%! >' zsh --no-rcs --histignorespace
} 1 > true ignore me
} 2 >this command will really be event 1
} 2 >
Hrm. The history number isn't ajusted until the hend() call of the input
command following the one to be ignored. That's because the previous
line actually CAN be referenced as (in the example above) !1 while you
are at the prompt that says "2 > ".
So there's an inherent conflict here; for a short while, there effectively
are two history events both numbered the same. You're either going to be
misled about what the last command was numbered, or about what the current
command will be numbered. This actually works well for HIST_IGNORE_DUPS
because the two identical commands are collapsed onto the same number, but
in other cases cases you end up with !N references where N finds something
that doesn't match your terminal scrollback.
Possible approaches:
(0) Do nothing.
(1) Make the numbering match the "what it will be" case.
(a) Introduce a second history counter used only in prompt expansion
that skips incrementing at hbegin() time [rather than hend()].
(b) Do a significant rework of hist.c so the "curhist" variable can
serve that role correctly.
(2) Rework history to leave holes in the number sequence when an event
is skipped. I believe this is already done for HIST_IGNORE_ALL_DUPS
and HIST_EXPIRE_DUPS_FIRST when the older duplicate is dropped. The
history is stored in a hash table, so event numbers are just keys in
the hash and holes are (I think) not an issue.
I'm not going to jump in on implementing any of the above any time soon,
but perhaps we can reach consensus on which is the best thing and then
somebody else can tackle it.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author