ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.24k stars 359 forks source link

opam autocompletion fails pattern matching composed flags on zshell #5312

Open rkv0id opened 2 years ago

rkv0id commented 2 years ago

The auto-completion in zshell has a weird output when it comes to composed arguments/flags. As an example, here's the output of the opam auto-completion for the opam switch command:

--help           export           invariant        listN45available   set              setN45invariant
create           import           link             reinstall        setN45base         show
default          install          list             remove           setN45description

To solve this, I had to modify all the sed patterns that try to replace the \N'45' character by - in the complete.zsh script as such: 's%\\-\|\\N'"'45'"'%-%g' to 's%\\N'"'45'"'%-%g' This way, the output of completions is fixed for all composed flags. Same opam switch completion example:

--help           export           invariant        list-available   set              set-invariant
create           import           link             reinstall        set-base         show
default          install          list             remove           set-description
kit-ty-kate commented 2 years ago

I'm using zsh as well and can't reproduce this issue. Could you past your .zshrc somewhere? Maybe there is an option somewhere that makes the behaviour different.

(tested using zsh 5.9 on linux)

dra27 commented 2 years ago

Another possibility - is the sed command GNU sed or something more limited? \| is a GNU-ism - perhaps we should split that into two s commands for maximum portability.

kit-ty-kate commented 2 years ago

Ah indeed. I just tested with zsh 5.9 on FreeBSD and i am now able to reproduce the bug

rkv0id commented 2 years ago

Indeed, when I pointed to GNU-sed, the out-of-box config worked just fine.