Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uu_test binary alias [ causes issues for Zsh completions #5579

Open
manu-schaaf opened this issue Nov 24, 2023 · 3 comments
Open

uu_test binary alias [ causes issues for Zsh completions #5579

manu-schaaf opened this issue Nov 24, 2023 · 3 comments

Comments

@manu-schaaf
Copy link

Issue

Using the Zsh completions of the coreutils binary created by running cargo run completion coreutils zsh results in an error:

coreutils _coreutils:1418: invalid subscript
_coreutils:1419: bad pattern: _coreutils__[_commands
_coreutils:23: bad pattern: [
_coreutils:23: bad pattern: [

Description

Creating completions using cargo run completion coreutils zsh will create completions for the uu_test create and thus both test and [ binaries as given here:

coreutils/build.rs

Lines 60 to 63 in 97d30bd

"uu_test" => {
phf_map.entry("test", &map_value);
phf_map.entry("[", &map_value);
}

This results in a completions file containing the following:

  • lines 689-694
    ([)
    _arguments "${_arguments_options[@]}" \
    '-h[Print help]' \    
    '--help[Print help]' \
    && ret=0
    ;;
  • lines 1177-1180
    ([)
    _arguments "${_arguments_options[@]}" \
    && ret=0              
    ;;
  • lines 1418-1427
    (( $+functions[_coreutils__[_commands] )) ||
    _coreutils__[_commands() {
        local commands; commands=()
        _describe -t commands 'coreutils [ commands' commands "$@"
    }
    (( $+functions[_coreutils__help__[_commands] )) ||
    _coreutils__help__[_commands() {
        local commands; commands=()
        _describe -t commands 'coreutils help [ commands' commands "$@"
    }

Each of the snippets above contain invalid opening square brackets, resulting in the shown errors when using the generated completions in Zsh.

Workaround

Removing line 62 in build.rs fixes the issue:

phf_map.entry("[", &map_value);

Background

I installed the multicall binary from source and created the completions as given above, placing them in $FPATH. I am using Zsh 5.9.4 (with Oh My Zsh) on an Arch-based distro.

@tertsdiepraam
Copy link
Member

We can't remove the [ alias there unfortunately, because we still need to support the alias, but we maybe we can skip generating completions for it? Alternatively, the [ should be an optional feature, since it is a built-in in zsh, so people can decide (based on their shell) whether they want it or not.

@sylvestre
Copy link
Contributor

or propose a fix in zsh :)

@tertsdiepraam
Copy link
Member

I think it's intentional on zsh's side because [ is a built-in? Maybe not though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants