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

Re: Completion issue when zsh is not the default shell



On Fri, 2018-10-26 at 16:25 +0200, Julien Nicoulaud wrote:
> On my work machine bash is the default shell (AD accounts...), and I have
> an issue with the SSH completion:
> 
> ssh sto<TAB>bash: _ssh_hosts: command not found...
> 
> Trace file (see line 622): https://pastebin.com/raw/eE6XJbg2
> 
> It looks like at some point bash is invoked, which tries to resolve
> _ssh_hosts and fails.
> 
> If I explicitly "autoload _ssh_hosts", it works correctly. It looks like a
> bug to me ?

It clearly shouldn't be running bash, but it's entirely unclear from
what you say why it actually is.  So I'm just having to guess.

Presumably _ssh_hosts is being found by your $path, rather than your
$fpath, so being executed as a command rather than function  It's not
clear why your system would be set up to find _ssh_hosts that way --- it
means your shell function directory is being searched for commands --- but
it's not actually a problem in general so long as the "autoload" has
been done.

Given that explicitly using "autoload" works, that means _ssh_hosts *is*
also being found along $fpath.

So the issue is it's not being marked for autoload automatically.  I can
think of a few reasons for this:

1. When "compinit" is run, $fpath isn't yet set up properly.  You'd
need to track this down in the initialisation sequence.  "compinit"
clearly is being run, or the shell wouldn't know about any association
between ssh completion _ssh_hosts.

2. You're hitting an old .zcompdump file that doesn't autoload this
but for some reason doesn't get detected as out of date.  This isn't
particularly likely but "rm ~/.zcompdump*" is an easy thing to try and
only incurs a one-off reload penalty.

3. There's an alternative _ssh_hosts early in your $fpath and it
doesn't contain the first line needed by the completion system,

#autoload

that you'll see in the file that comes with zsh.  This is probably my
top guess.  Have a look at

print -l $^fpath/_ssh_hosts(N)

(expand fpath to include any occurence of _ssh_hosts but remove any
entries that aren't matched as files).

pws




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