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

Re: completion bug: treats substitution of unset parameter as empty string



>>>>> On September 10, 2009 Peter Stephenson <pws@xxxxxxx> wrote:

> See _comp_options and _comp_setup in compinit and the use of _comp_setup
> in _main_complete.

OK, thanks for the pointer..

Here's a patch to fix the originally reported problem - that
_path_files incorrectly treats a parameter expansion of an
unset parameter as the empty string, i.e. that

% ls $foobar/ <tab>

lists completions under '/'.

thanks,
Greg


Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.47
diff -u -r1.47 _path_files
--- Completion/Unix/Type/_path_files	5 Aug 2009 00:46:45 -0000	1.47
+++ Completion/Unix/Type/_path_files	10 Sep 2009 14:26:53 -0000
@@ -247,7 +247,9 @@
   # meant as a partial path.
 
   linepath="${(M)pre##*\$[^/]##/}"
+  setopt nounset # do not treat an unset parameter expansion as the empty string
   eval 'realpath=${(e)~linepath}' 2>/dev/null
+  setopt unset
   [[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1
   pre="${pre#${linepath}}"
   i='[^/]'



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