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

Bug with parameter expansion



I get the following with tab bound to expand-or-complete:

zsh -f
export PATH=$PATH<tab>

expands to:
export PATH\=/usr/bin:/etc:....

In other words, the equals is quoted which it shouldn't be. Also, if I
expand $PWD or some variable containing a directory name, I get a space
suffix when a slash would be more useful. What would be nice is if there
was a check to see if the variable contained a directory name and a
slash used for the suffix if so.

There is another case where I'd like a slash suffix to be used:

I have a function named switch which outputs a directory name which it
generates from the current directory so I regularly use it as $(switch).

If I type:
cd $(switch)<tab> it expands and uses a space suffix which is fine.
cd $(switch)/<tab> it expands and uses a slash suffix which is very
useful.
cd $(switch)/Rel<tab> it expands, leaves '/Rel' on the end and uses a
space suffix.

The second case seems to be some sort of special case. What I would like
is for the third case to be no different, i.e. a / after the $(...) is
significant in deciding the suffix and any following characters are
irrelevant (unless there is another $(...) later on the line). Another
way of thinking of it is that I want it to try to do completion after
the expansion - basically, in the third case, I want to complete to the
'Releases' directory.

In the longer term, it would be nice to have a mechanism where variables
can be generated each time they are read by a shell function. Ksh 93
apparently has such a feature using two 'discipline functions' -
varname.get and varname.set which are each called when the variable is
read and assigned to respectively. This would be useful to me with my
switch (and other related functions) because variables are more
convenient on the command line and it could be read twice so left intact
on the command-line while allowing completion after it. I can think of
many other uses though, especially with associative arrays.

Oliver Kiddle



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