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

complete -C not acting right #51

Open
perlancar opened this issue Jul 24, 2021 · 0 comments
Open

complete -C not acting right #51

perlancar opened this issue Jul 24, 2021 · 0 comments

Comments

@perlancar
Copy link

perlancar commented Jul 24, 2021

I have CLI scripts that complete themselves (complete -C SCRIPTNAME SCRIPTNAME) written in Perl. When doing completion, bash-completion.el seems to call a script multiple times and without COMP_LINE and COMP_POINT set, making completion fail.
In the example below, I am using the remove-pdf-password script, available from CPAN (https://metacpan.org/pod/remove-pdf-password).

I have enabled logging in my script to see environment varible. When in bash:

% remove-pdf-password <tab>

will log this line:

[Sat Jul 24 08:14:45 2021] [prog /home/s1/perl5/perlbrew/perls/perl-5.30.2/bin/remove-pdf-password] [pid 8508] [uid 1000] COMP_LINE=<remove-pdf-password -> (21 char(s)) COMP_POINT=<21>

When in M-x shell, doing the same causes this to be logged instead:

[Sat Jul 24 08:15:01 2021] [prog /home/s1/perl5/perlbrew/perls/perl-5.30.2/bin/remove-pdf-password] [pid 8747] [uid 1000] COMP_LINE=<> (0 char(s)) COMP_POINT=<>
[Sat Jul 24 08:15:01 2021] [prog /home/s1/perl5/perlbrew/perls/perl-5.30.2/bin/remove-pdf-password] [pid 8748] [uid 1000] COMP_LINE=<> (0 char(s)) COMP_POINT=<>
[Sat Jul 24 08:15:01 2021] [prog /home/s1/perl5/perlbrew/perls/perl-5.30.2/bin/remove-pdf-password] [pid 8749] [uid 1000] COMP_LINE=<> (0 char(s)) COMP_POINT=<>

Relevant lines from output of M-x bash-completion-debug:

commandline: <<EOF
__emacs_complete_pre_command;  echo -n "^[^[pwd=${PWD}^[^[";__EMACS_COMPLETE_WRAPPER='COMP_LINE='\''remove-pdf-password '\''; COMP_POINT=$(( 1 + ${#COMP_LINE} )); COMP_CWORD=1; COMP_WORDS=( remove-pdf-password '\'''\'' ); remove-pdf-password remove-pdf-password '\'''\'' remove-pdf-password' compgen -F __emacs_complete_wrapper -- '' 2>/dev/null
EOF

status: 1
process: #<process shell>
output-buffer: <<EOF
^[^[pwd=/zpool_host_mnt/mnt/home/s1^[^[remove-pdf-password: ERROR 400: Argument 'files' fails validation: @[1]: Length must be at least 1
EOF

bash-major-version: 4
emacs-version: "25.2.2"
completion-ignore-case: t
context: [cl-struct-completion "remove-pdf-password "
                      ("remove-pdf-password" "")
                      1 "" 1797 "" nil
                      ("-C" "remove-pdf-password")
                      "\"'@><=;|&(:" nil]

complete-p: ((nil "-F" "_shcompgen_loader")
 ("shcompgen" "-C" "shcompgen")
 ("renwd-cd" "-C" "renwd")
 ("cdpm" "-F" "_cdpm")
 ("remove-pdf-password" "-C" "remove-pdf-password")
 ("cds" "-F" "_cds"))
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

1 participant