Re: bash: History substitution doesn't happen after ^V^J.
From:
Ralph Corderoy
Subject:
Re: bash: History substitution doesn't happen after ^V^J.
Date:
Wed, 20 Oct 2004 11:31:48 +0100
Hi Chet,
> > $ echo !$<Return>
> > foo
> > $ echo 'a^V^J
> > b' !$<Return>
> > a
> > b !$
> > $
>
> History expansion is done on a per-line basis, not per-token. It is
> performed before the shell parser sees the line.
OK.
> At the point the second line is read and history expanded, the
> parser's state is still `open single quote', so expansion is
> inhibited.
I understand.
> I'd rather err on the side of not performing history expansion where
> it could possibly be done instead of performing it when it should not.
Couldn't we pick the middle ground and do it when it's right and not
when it's not? :-) That
$ echo 'a b' !$
$ echo 'a
b' !$
produce different results seems to be a bug, even if it the behaviour is
understandable.
There's already quoted-histchar-checking present that stops expansion:
$ echo foo
foo
$ echo !$ \!$ 'a !$ b' \
> !$ z
foo !$ a !$ b z
$
Wouldn't it just be in the in-quoted-string state at the beginning of
line two but leave that on encountering the close quote?
I've no patch to provide, but I'd rather see this left open as a bug to
be fixed one day rather than closed under `as designed'.
Cheers,
Ralph.