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

Re: zsh sometimes freezes when completing a command

On Mar 16,  1:35am, Benjamin R. Haskell wrote:
} From a similar discussion w/ subject: 'Avoid LDAP hit during 
} completion'[1], Peter's suggestion lead me tangentially to this section, 
} from somewhere in zshall (zstyle(?) .. Standard styles):
} users  This may be set to a list of usernames to be completed.   If  it
} 	   is  not set all usernames will be completed.  Note that if it is 
} 	   set only that list of users will be completed; this  is  because 
} 	   on some systems querying all users can take a prohibitive amount 
} 	   of time.

Hmm, ramifications of this that didn't sink in before have just occurred
to me.  One can set the style with "zstyle -e" to cause an eval at the
time of lookup, and therefore control the mechanism by which user lookup
is peformed (use an external app for LDAP, for example).

I don't have a clever example to offer just now, but food for thought.
} As pws explained in much more detail in that thread, that might not be 
} the only place users would be generated.  But, things also may have been 
} cleaned up since 2005.

Users are generated by expanding a reference to the "userdirs" variable
defined in the zsh/parameter module.  This happens in these locations:

_users in which case the zstyle suppresses the userdirs reference; 
_expand when expanding any word that begins with tilde;
_chown when completing the user to whom to assign ownership;
_mailboxes when completing abbreviated mailbox names for mush or zmail;
_tilde_files when completing ~someuser/somepath...

Plus any completion loaded via the bashcompinit compatibility package
that runs "compgen -A users".

The _tilde_files case is interesting because if completing ~someuser
(without the trailing path) it calls _users and obeys the style.  The
userdirs reference with the trailing path is always $userdirs[$user]
to confirm that user home directory exists, so perhaps that doesn't
trigger an expensive lookup or a large result set.

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