Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: History expansion modifiers :t, :h, :r and :e break quoting in some cases
On Tue, 02 Jul 2013 19:43:56 +0200
Axel Beckert <abe@xxxxxxxxxxxxxxx> wrote:
> Today I was slightly confused about the "`quote>" prompt after the
> following commands:
>
> % echo 'foo/bar'
> foo/bar
> % echo !$:h
> `quote> ^C
> echo 'foo
> %
>
> (I manually added the "^C" above where I pressed Ctrl-C. My real-life
> case was more complex and had blanks in the file names and hence
> qualifies the quoting. :-)
>
> So ":h" seems not only to strip "/bar" as I would have expected but
> also strips the trailing single quote.
Yes, the history modifiers know essentially nothing about shell syntax.
They are applied very early in processing, before any lexical analysis.
The only workaround I can see that would process the command line more
intelligently would be some function running in the line editor, which
has access to more intelligence, including some existing functions for
analysing command lines. However, that's not a 5-minute job.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author