On Wed, Dec 3, 2014 at 10:19 AM, Eduardo A. Bustamante López <dual...@gmail.com> wrote: > On Wed, Dec 03, 2014 at 08:57:26AM +0100, Piotr Grzybowski wrote: >> I think in this case, history_expand lib/readline/histexpand.c:905 is >> invoked with hstring="b\" | echo '!'", and goes wrongly into history >> expansion. [..]
> Yes, the issue is tricky, because you don't have access to the whole buffer > there (shell_getc), just to the current line (shell_input_line), but the > current line is a fragment of the whole command. > > What I don't understand is why bash does history expansion inside shell_getc, > shouldn't it be easier to do it once you have the whole thing? > > It seems hard to change that, though. Yeah. This is probably due to the fact that bash returns to the prompt. And I agree, that changing that would probably be more of a design modification than just a bug fix. Fixing the loop in history_expand could also get tricky, which probably can be done with more or less dirty hacks, involving passing and checking a flag indicating that it is a continuation of the command. cheers, pg