-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fish completion fails with quotes in argument #1214
Comments
@marckhouzam PTAL |
This issue is being marked as stale due to a long period of inactivity |
Sorry @Luap99 I forgot about this one. I'll try to take a look soon. |
I'm finally looking into this and I believe the issue is that for fish, command errors cannot be re-directed. This means that if a command has unbalanced quoting, like our case, it will print an error. This seems to mean that to avoid the error printouts being visible, we would need to catch the case of unbalanced quoting ourselves, which I don't think is trivial (e.g, One idea I thought of is that we could execute the command not directly with
which prints the error message
which properly redirects the error output to We should maybe check for the presence of @Luap99 could you give some more info on when this situation may occur? |
Why not
I only hit this issue while testing. I don't think I would have encountered this problem in a normal use case. The fact that no one has opened a similar issue or commented on this one leads me to believe that it is not important to fix this problem. |
Hey that works (I didn't expect it to)! And I think that is safer than using In trying to test further I thought of trying completion when using:
and these currently don't work for fish. This is because of the use of I'll open a new issue for this new bug and post a PR to address this one and the new one. |
I've opened #1306 |
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
I've added the discussed fix for this issue to #1249 |
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
Fixes spf13#1214 Fixes spf13#1306 Signed-off-by: Marc Khouzam <[email protected]>
* Fix fish for ShellDirectiveNoSpace and file comp For fish shell we achieve ShellDirectiveNoSpace by outputing a fake second completion with an extra character. However, this extra character was being added after the description string, instead of before. This commit fixes that. It also cleans up the script of useless code, now that fish completion details are better understood. Signed-off-by: Marc Khouzam <[email protected]> * Handle case when completion starts with a space Fixes #1303 Signed-off-by: Marc Khouzam <[email protected]> * Support fish completion with env vars in the path Fixes #1214 Fixes #1306 Signed-off-by: Marc Khouzam <[email protected]> * Update based on review 1- We use `set -l` for local variable to make sure there are no conflicts with global variables 2- We use `commandline -opc` which: a) splits the command line into tokens (-o) b) only considers the current command (-p) (e.g., echo hello; helm <TAB>) c) stops at the cursor (-c) 3- We extract the last arg with `commandline -ct` and escape it to handle the case where it is a space, or unmatched quote. 4- We avoid looping when filtering on prefix. 5- We don't add a fake comp for ShellCompDirectiveNoSpace when the completion ends with any of @=/:., as fish won't add a space Signed-off-by: Marc Khouzam <[email protected]>
* Fix fish for ShellDirectiveNoSpace and file comp For fish shell we achieve ShellDirectiveNoSpace by outputing a fake second completion with an extra character. However, this extra character was being added after the description string, instead of before. This commit fixes that. It also cleans up the script of useless code, now that fish completion details are better understood. Signed-off-by: Marc Khouzam <[email protected]> * Handle case when completion starts with a space Fixes #1303 Signed-off-by: Marc Khouzam <[email protected]> * Support fish completion with env vars in the path Fixes spf13/cobra#1214 Fixes spf13/cobra#1306 Signed-off-by: Marc Khouzam <[email protected]> * Update based on review 1- We use `set -l` for local variable to make sure there are no conflicts with global variables 2- We use `commandline -opc` which: a) splits the command line into tokens (-o) b) only considers the current command (-p) (e.g., echo hello; helm <TAB>) c) stops at the cursor (-c) 3- We extract the last arg with `commandline -ct` and escape it to handle the case where it is a space, or unmatched quote. 4- We avoid looping when filtering on prefix. 5- We don't add a fake comp for ShellCompDirectiveNoSpace when the completion ends with any of @=/:., as fish won't add a space Signed-off-by: Marc Khouzam <[email protected]>
The fish completion script prints ugly traces if quotes are not balanced in the argument.
To reproduce:
./testprog '[TAB]
This happens with single and double quotes. Technically the completion still works and offers file completion but the traces makes this unusable.
I also checked this with zsh, bash, #1146 and #1208 but only fish is affected. All other shells offer file completion, which is in my eyes the right thing.
The text was updated successfully, but these errors were encountered: