Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion bug: treats substitution of unset parameter as empty string
- X-seq: zsh-workers 27260
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: completion bug: treats substitution of unset parameter as empty string
- Date: Thu, 10 Sep 2009 15:40:53 +0100
- In-reply-to: <m3hbvana7h.fsf@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
- References: <19056.37899.24683.999959@xxxxxxxxxxxxxxxxxx> <m3pra0oj0b.fsf@xxxxxxxxxxxxxx> <200909100926.n8A9QFTh025636@xxxxxxxxxxxxxx> <m3hbvana7h.fsf@xxxxxxxxxxxxxx>
On Thu, 10 Sep 2009 10:30:42 -0400
Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:
> 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 '/'.
That's fine, however I think (belatedly answering your other question)
that, since we don't need to backport this anywhere, using an anonymous
function would be neater---so we're not relying on the value of "nounset"
outside. In practice if it were set outside all hell would break loose, so
this is pretty pernickety, but perhaps it's a useful precedent.
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:36:56 -0000
@@ -247,7 +247,11 @@
# meant as a partial path.
linepath="${(M)pre##*\$[^/]##/}"
- eval 'realpath=${(e)~linepath}' 2>/dev/null
+ function {
+ # do not treat an unset parameter expansion as the empty string
+ setopt localoptions nounset
+ eval 'realpath=${(e)~linepath}' 2>/dev/null
+ }
[[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1
pre="${pre#${linepath}}"
i='[^/]'
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author