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

Re: expansion of environment variables



On Thu, 5 Mar 2009, ruud grosmann wrote:

[...]

The new version has a feature that is not in the 3.0 version. I would
like to disable the feature, but I am not sure if an option exist for
that one. Maybe you can help me.


The feature is about expansion of variables during file completion.
Assume my directory contains

1234.log   1234.xml  2345.xml

when I set variable key to '2345' and I do

$ /opt/archives/scripts/bin/convert $key.<TAB>

the OLD version expands this to

$ /opt/archives/scripts/bin/convert $key.xml

whereas the new version expands it to

$ /opt/archives/scripts/bin/convert 2345.xml

I would like to have the old behaviour in my new zsh, so that I can
reuse the command line for different values of key. Since it is a new
feature, I suspect there must be a way to prevent the shell from
substituting the variable with its value. Am I overlooking it in the
docs?

I don't get the "new" behavior in zsh-4.3.6 for a similar example with the following options set:

$ setopt
autocd
noautomenu
nocheckjobs
extendedglob
extendedhistory
globdots
histignoredups
histignorespace
histnostore
histsubstpattern
nohup
incappendhistory
interactive
monitor
nonotify
promptsubst
pushdsilent
shinstdin
zle
# output of allopt at: http://benizi.com/zsh-opt-2009-03-05.txt

$ key=tmp
$ l $key/zzz.<TAB>
zzz.php  zzz.txt


But, I also get the following behaviors, which seem odd (though not inexplicable) to me:

$ key=tmp/zzz
$ l $key.<TAB>
# (doesn't offer any completions)
$ l ${key}.<TAB>
# no completions


$ key=tm
$ l ${key}p/z<TAB>
$ l ${key}p/zzz.

I'm sure this is an uncommon problem to have [wanting to tab-complete a variable that contains a partial *filename*, rather than just a partial path]. It just strikes me as weird that it's not consistently doing:

1. expand variable, but don't insert that expansion into the line
2. attempt completion


Another example:

$ mkdir -p aaa/bbb/ccc/ddd
$ touch aaa/bbb/ccc/ddd/eee.one
$ touch aaa/bbb/ccc/ddd/eee.two

$ key=aaa/bbb/ccc/ddd/eee
$ l ${key}.<TAB>
# nothing

$ key=aaa/bbb/ccc/d
$ l ${key}d<TAB>
# nothing

$ l ${key}dd<TAB>
# nothing

$ l ${key}dd/<TAB>
# completes to ambiguity point:
$ l ${key}dd/eee.<TAB>
eee.one  eee.two

Best,
Ben



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