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

Re: problem with quoting in completion function



On Apr 14, 12:16am, Borsenkow Andrej wrote:
}
} I spent some time trying to understand why the following (suggested by
} Sven) does not work:
} 
}  compset -P "*,"
}  all_sources=( ${all_sources:#(${~IPREFIX//,/|})} )

On Apr 14, 12:23am, Borsenkow Andrej wrote:
}
} > It turned out, completion internally quotes IPREFIX,
} 
} Of course it does not quote IPREFIX. It quotes word inserted in command
} line that becomes IPREFIX on next try.
} 
} Is there any general way inside completion to "dequote" word from
} command line? 

I was going to compare this to Jeremy Dolan's bug from the other day, but
after a bit of thought I see that it isn't, really -- the quoting of the
IPREFIX theoretically shouldn't matter, because it's ignored, after all.

I wonder if ${(Q)IPREFIX} would do what you need?  What should happen if
the ignored prefix contains e.g. an unmatched single-quote?  Probably you
should examine $compstate[all_quotes] to decide what to do.

Here's a different example of Jeremy's bug:

schaefer<512> ls "foo\<TAB>
Completing corrections
foo\!baz   foo\!bar 
Completing original
foo\\

Note that it thinks the original string has two backslashes, and only
supplies the other two choices as corrections.

In that case, the completion internals really did quote $PREFIX.  It's
already got both backslashes by the time _main_complete starts calling
the completers.  A quick peek at callcompfunc() shows that the prefix
gets passed through multiquote() in all cases except math expressions.
Again it might be possible to do something different depending on the
quoting state, but in this case it'd have to be in the C code.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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