Fix loading issue under ZSH #65

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@jimeh

jimeh commented Sep 2, 2012

I'm not sure this is something related specifically to my setup, but here goes.

As far as I know ZSH tries to be Bash-compatible by among other things, letting Bash completion work via the complete command. Hence checking for it before compctl under ZSH will always make it think it's running under Bash.

This fix simply checks for ZSH's compctl first, which Bash does not have, and hence works correctly under both Bash and ZSH.

Fix loading issue under ZSH
I'm not sure this is something related specifically to my setup, but
here goes.

As far as I know ZSH tries to be Bash-compatible by among other things,
letting Bash completion work via the `complete` command. Hence checking
for it before `compctl` under ZSH will always make it think it's running
under Bash.

This fix simply checks for ZSH's `compctl` first, which Bash does not
have, and hence works correctly under both Bash and ZSH.
@rupa

This comment has been minimized.

Show comment
Hide comment
@rupa

rupa Sep 3, 2012

Owner

I think it is your setup:


~$ complete
zsh: command not found: complete

I wonder where your zsh got a complete command. What does which complete or type complete tell you?

I guess I wouldn't mind switching the order - if I do, I'll probably not use this pull request tho, simply cause I want to keep the zsh compatibility warning in the first line of commits for a while longer ...

Owner

rupa commented Sep 3, 2012

I think it is your setup:


~$ complete
zsh: command not found: complete

I wonder where your zsh got a complete command. What does which complete or type complete tell you?

I guess I wouldn't mind switching the order - if I do, I'll probably not use this pull request tho, simply cause I want to keep the zsh compatibility warning in the first line of commits for a while longer ...

@jimeh

This comment has been minimized.

Show comment
Hide comment
@jimeh

jimeh Sep 3, 2012

After a little bit of research I've found an explenation on the zshcompsys man page:

The function bashcompinit compatibility with bash’s programmable completion system. When run it will define the functions, compgen and complete which correspond to the bash builtins with the same names. It will then be possible to use completion specifications and functions written for bash.

As far as I know there's nothing in my setup that calls bashcompinit. But it seems as if in ZSH 5.x bashcompinit is run by default. Or at least since April last year by the look of this patch: http://www.spinics.net/lists/git/msg156326.html

I don't mind if you don't use my specific commit, for the time being I have my dotfiles using my own fork :)

And lastly, here's the output for the commands you asked about:

jimeh@air ~$ zsh --version
zsh 5.0.0 (x86_64-apple-darwin12.0.0)
jimeh@air ~$ complete
jimeh@air ~$ type complete
complete is a shell function
jimeh@air ~$ which complete
complete () {
        emulate -L zsh
        local args void cmd print remove
        args=("$@") 
        zparseopts -D -a void o: A: G: W: C: F: P: S: X: a b c d e f g j k u v p=print r=remove
        if [[ -n $print ]]
        then
                printf 'complete %2$s %1$s\n' "${(@kv)_comps[(R)_bash*]#* }"
        elif [[ -n $remove ]]
        then
                for cmd
                do
                        unset "_comps[$cmd]"
                done
        else
                compdef _bash_complete\ ${(j. .)${(q)args[1,-1-$#]}} "$@"
        fi
}

jimeh commented Sep 3, 2012

After a little bit of research I've found an explenation on the zshcompsys man page:

The function bashcompinit compatibility with bash’s programmable completion system. When run it will define the functions, compgen and complete which correspond to the bash builtins with the same names. It will then be possible to use completion specifications and functions written for bash.

As far as I know there's nothing in my setup that calls bashcompinit. But it seems as if in ZSH 5.x bashcompinit is run by default. Or at least since April last year by the look of this patch: http://www.spinics.net/lists/git/msg156326.html

I don't mind if you don't use my specific commit, for the time being I have my dotfiles using my own fork :)

And lastly, here's the output for the commands you asked about:

jimeh@air ~$ zsh --version
zsh 5.0.0 (x86_64-apple-darwin12.0.0)
jimeh@air ~$ complete
jimeh@air ~$ type complete
complete is a shell function
jimeh@air ~$ which complete
complete () {
        emulate -L zsh
        local args void cmd print remove
        args=("$@") 
        zparseopts -D -a void o: A: G: W: C: F: P: S: X: a b c d e f g j k u v p=print r=remove
        if [[ -n $print ]]
        then
                printf 'complete %2$s %1$s\n' "${(@kv)_comps[(R)_bash*]#* }"
        elif [[ -n $remove ]]
        then
                for cmd
                do
                        unset "_comps[$cmd]"
                done
        else
                compdef _bash_complete\ ${(j. .)${(q)args[1,-1-$#]}} "$@"
        fi
}
@rupa

This comment has been minimized.

Show comment
Hide comment
@rupa

rupa Sep 3, 2012

Owner

Thanks, I made this change.

Owner

rupa commented Sep 3, 2012

Thanks, I made this change.

@rupa rupa closed this Sep 3, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment