Closed sio closed 4 years ago
@geekscrapy, now completion should work as you described
Thanks, I just tested and I get odd behavior - using commit 7885c8e. The following gets printed to the terminal as part of the auto-complete:
$ cd /Vol<tab>/var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.654uF2X9
umes/
/Volumes/Macintosh HD
^ The last line is what I would expect (as the second option to complete), and the unexpected behavior being the printout of the following path one the first time
/var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.654uF2X9 umes/
I understand what that garbage output means, but there are multiple places where it could've come from. Since this does not happen on my machines (Linux, Windows), it may be related to some little differences in GNU and BSD tooling. Can you help me with debugging?
set -v; set -x
before attempting completion. It enables printing a lot of useful debugging information$ cd /Vol+ _bcpp_complete directory
+ local WILDCARDS ACTION LINE OPTION INPUT QUOTE
+ ACTION=directory
+ [[ _directory == \_\-\d ]]
+ [[ 1 -ge 0 ]]
+ INPUT=/Vol
+ [[ / == \' ]]
+ [[ / == \" ]]
+ QUOTE=
+ COMPREPLY=()
+ compopt -o nospace
+ compopt -o bashdefault
+ compopt -o default
+ [[ -e /Vol ]]
++ _bcpp_put_wildcards /Vol
++ local PROCESSED TILDE_EXPANSION INPUT
++ INPUT=/Vol
+++ echo /Vol
+++ gsed -Ee 's:([^\*\~])/:\1*/:g;
s:([^\/\*])$:\1*:g;
s:^(\~[^\/]*)\*\/:\1/:;
s:(\.+)\*/:\1/:g;
s:(^|/)(\$[^/]+)\*(/|$):\2\3:g'
++ PROCESSED='/Vol*'
+++ printf %q '/Vol*'
+++ gsed -e 's:^\\\~:~:g' -Ee 's:(^|/)\\(\$):\1\2:g'
++ eval 'TILDE_EXPANSION=/Vol\*'
+++ TILDE_EXPANSION='/Vol*'
++ [[ /Vol =~ ^/[a-zA-Z]/.* ]]
++ echo '/Vol*'
+ WILDCARDS='/Vol*'
+ local pipe
+ pipe=/var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.QnXEffjK
+ [[ -z /var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.QnXEffjK ]]
+ mkfifo -m 600 /var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.QnXEffjK
+ local monitor
+ [[ himvxBHs == *m* ]]
+ monitor=yes
+ [[ yes == yes ]]
+ set +m
+ _bcpp_silent_bg _bcpp_compgen '/Vol*' /var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.QnXEffjK
+ disown
+ return 0
+ local 'wildcards=/Vol*'
+ local pipe=/var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.QnXEffjK
+ compgen -G '/Vol*' '/Vol*'
+ read -r -d '
' LINE
+ [[ _directory == \_\d\i\r\e\c\t\o\r\y ]]
+ [[ ! -d /Volumes ]]
+ [[ -z /Volumes ]]
+ [[ -z '' ]]
++ printf %q /Volumes
+ LINE=/Volumes
+ COMPREPLY+=("$LINE")
+ read -r -d '
' LINE
+ rm -v /var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.QnXEffjK
/var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.QnXEffjK
+ [[ yes == yes ]]
+ set -m
umes
Aha, I see. Looks like you've set up a handy alias for rm :) I'll add a workaround for such cases, you don't need to change your configuration.
I fixed this in issue-10
branch and added automated tests for this case. Please try the updated version and let me know if it's ok to merge :)
Looks to have fixed it! 👍
Ok, I've merged the changes into master
Reported by @geekscrapy in comments:
I confirm the reported behavior. Issue affects only directory completion.
File completion (try
ls
) works almost as expected, but double slashes should be dropped.