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

Re: [PATCH] Quote components before using it is pattern



On 14 October 2008 17:01, JÃrg Sommer <joerg@xxxxxxxxxxxx> wrote:
> Hi,
>
>> A component might contain a character active in patterns, like * or ().
>> Take for example the path /tmp/foobar). Passing this and /tmp/foo123 as a
>> completion to _multi_parts results in an error:
>>
>> _multi_parts:147: bad pattern: (foo123|foobar))*
>>
>> The characters in the temporary variable tmp1 must be quote, before the
>> pattern is build with them.
>
> Here is a simple test that shows the error in the old version:
>
> % compdef '_multi_parts -- / mpcompletions' mptest
> % mpcompletions=( a/foo\) a/f123 )
> % mptest a/<TAB>
> _multi_parts:147: bad pattern: (foo)|f123)*

This patch sort of breaks completing when the first segment has spaces
for me. They don't appear in the initial listing, but typing the first
char of their name sometimes completes them.
% compdef '_multi_parts -- / mpcompletions' mptest
% mpcompletions=3D( 'foo bar' 'foo baz' bar baz )
% mptest <TAB>ba<TAB>
bar baz

In this particular test, the foo bar and foo baz don't seem to appear
at all in the list, but they _are_ accepted (ie a space is inserted)
when they are typed in full. Removing the added (q) fixes this but of
course breaks the original case again. I have no idea what the line
does or how it does it.

The realworld case is zip- and tar-files that contain files with spaces.

-- 
Mikael Magnusson



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