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

Re: Non-intuitive completion



On Dec 1,  2:47am, Phil Pennock wrote:
} Subject: Non-intuitive completion
}
} Also, this isn't necessarily a bug, as it's 'daft' on my part.  But the
} results are counter-intuitive, to me at least.
} 
} athenaeum% print $ZSH_*<TAB>
} 
} At which point the leading $ZSH_ is completely ignored and removed, and
} the * is expanded out to files in the current directory, as per usual.
} 
} Nothing special about the above choice of variable, except that <TAB>
} after the Z provides the next three characters.  I'm lazy and wanted
} both, so tried '*' to see what zsh would do.  I /know/ it's a filename
} glob, but shouldn't the leading text have some effect instead of being
} treated as null?

The default binding for tab is expand-or-complete.

The $ZSH_ is "treated as null" because as soon as you insert the '*' you
aren't doing completion any more, you're doing expansion.  The expansion
of $ZSH_ is empty if $ZSH_ is not set, so it vanishes.

If you don't want to switch on the fly from completion to expansion in
that way, then you have to rebind tab to complete-word.  Try

zsh% bindkey '^I' complete-word
zsh% print $ZSH_*<TAB>

Now it just feeps at you, because a '*' can't appear in a variable name.

Now, if you'd like to see some REALLY strange behavior, which definitely
IS a bug in my book, try

zsh% bindkey '^I' expand-or-complete
zsh% setopt nounset
zsh% print $ZSH_*<TAB>

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



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