Skip to content

Inconsistent with default completion behavior in simpler cases #10

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

Closed
sio opened this issue Nov 7, 2019 · 8 comments
Closed

Inconsistent with default completion behavior in simpler cases #10

sio opened this issue Nov 7, 2019 · 8 comments
Labels
bug Something isn't working

Comments

@sio
Copy link
Owner

sio commented Nov 7, 2019

Reported by @geekscrapy in comments:

Can confirm it's working now. All except when I do the following:
cd /etc

...And then TAB. "etc" is a directory and I would expect it to add the slash and then TAB again to start looping over the files and directories within "etc". But it just stops and doesn't autocomplete. It does this with all directories

I confirm the reported behavior. Issue affects only directory completion.

File completion (try ls) works almost as expected, but double slashes should be dropped.

@sio sio added the bug Something isn't working label Nov 7, 2019
@sio sio closed this as completed in 7f2b08a Nov 18, 2019
@sio
Copy link
Owner Author

sio commented Nov 18, 2019

@geekscrapy, now completion should work as you described

sio added a commit that referenced this issue Dec 3, 2019
@geekscrapy
Copy link

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 is pressed. As you can see, "umes/" is the correct first auto suggestion, which is printed after the random path.

/var/folders/gy/tk3qzc8d7_zc1kdm1yzl58yszv_8fz/T/bcpp_pipe.654uF2X9 umes/

@sio
Copy link
Owner Author

sio commented Dec 4, 2019

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?

  • You need to execute set -v; set -x before attempting completion. It enables printing a lot of useful debugging information
  • After that repeat your attempt at completion
  • A lot more extra stuff will be printed - paste it all here
  • You can close current shell - debug mode will not affect any other bash sessions

@sio sio reopened this Dec 4, 2019
@geekscrapy
Copy link

geekscrapy commented Dec 4, 2019

$ 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

@sio
Copy link
Owner Author

sio commented Dec 4, 2019

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.

@sio
Copy link
Owner Author

sio commented Dec 4, 2019

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 :)

@geekscrapy
Copy link

Looks to have fixed it!
👍

@sio
Copy link
Owner Author

sio commented Dec 4, 2019

Ok, I've merged the changes into master

@sio sio closed this as completed Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants