Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

History expansion modifiers :t, :h, :r and :e break quoting in some cases



Hi,

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.

The same happens with ":e" as well as with ":t" or ":r" and the
leading single quote:

% echo 'foo/bar.bla'
foo/bar.bla
 echo !$:e
`quote> ^C
echo bla'
%

% echo 'foo/bar'
foo/bar
% echo !$:t
`quote> ^C
echo bar'
%

% echo 'foo/bar.bla'
foo/bar.bla
% echo !$:r
`quote> ^C
echo 'foo/bar
%

It also behaves the same way with double quotes instead of single
quotes.

At least for enclosing double and single quotes, I would have expected
that these are not stripped on :t or :h. I can imagine that it may be
harder to implement for more complex quoting variants like

% echo "foo '"'/"'"' bla"
foo '/"' bla
% 

Initially noticed with zsh 4.3.17 in Debian Wheezy, but also
reproducible with zsh 5.0.2 in Debian Unstable.

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@xxxxxxxxxxxxxxx  (Mail)
 X   See http://www.asciiribbon.org/              | abe@xxxxxxxxx (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://noone.org/abe/ (Web)



Messages sorted by: Reverse Date, Date, Thread, Author