On Wed, Dec 03, 2014 at 08:57:26AM +0100, Piotr Grzybowski wrote: > Hey, > > I think in this case, history_expand lib/readline/histexpand.c:905 is > invoked with hstring="b\" | echo '!'", and goes wrongly into history > expansion. > Not that I know how to fix it ;-) 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? zsh does that: | dualbus@hp ~ % echo x | x | dualbus@hp ~ % echo " | dualbus@hp ~ dquote> !! | dualbus@hp ~ dquote> " | echo " | echo x | " | | echo x Also tcsh: | dualbus@hp ~ % tcsh | hp:~> echo x | x | hp:~> echo "\ | ? !!\ | ? " | echo "\ | echo x\ | " | | echo x | | hp:~> vs bash: | dualbus@hp:~$ echo x | x | dualbus@hp:~$ echo " | > !! | echo " | | echo | dualbus@hp:~$ It seems hard to change that, though.