Skip to content

uu_test binary alias [ causes issues for Zsh completions #5579

@manu-schaaf

Description

@manu-schaaf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions