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

Improve bash completion with compopt #5240

Merged
merged 4 commits into from
Jan 22, 2024

Conversation

sudotac
Copy link
Contributor

@sudotac sudotac commented Dec 3, 2023

This PR tries to improve bash completion support.

@sudotac sudotac force-pushed the improve-bash-completion-with-compopt branch from 6118719 to 78b1ff0 Compare December 3, 2023 08:45
@epage
Copy link
Member

epage commented Dec 4, 2023

Could you insert a commit at the beginning that updates complete for these cases and then in each commit as things get fixed, the asserts in that test can be updated?

We've added support for testing completions but it'd be a lot of work to go back and add them for all previous issues but I'd like for us to be making sure we cover them for future ones.

@epage
Copy link
Member

epage commented Dec 4, 2023

Also, will this cause problems for people on older bash? See #5190.

@sudotac sudotac force-pushed the improve-bash-completion-with-compopt branch from 78b1ff0 to f24a9cc Compare December 5, 2023 13:01
@sudotac
Copy link
Contributor Author

sudotac commented Dec 5, 2023

Moved the test change to 6e1fae9. I hope I fixed this correctly.

Also, will this cause problems for people on older bash? See #5190.

I think it would work on bash 4.0 or later.
According to the bash changelog (warning: very long), compopt was introduced in bash 4.0 and the options (-o filenames, -o plusdirs and -o nospace) are available on older versions.

In my opinion, bash 4.0 is old enough to be a minimum supported version.
As far as I've searched on repology, no "major" distribution supports bash 4.0 or older. (It depends on what is "major" though...)

@epage
Copy link
Member

epage commented Dec 5, 2023

In my opinion, bash 4.0 is old enough to be a minimum supported version.
As far as I've searched on repology, no "major" distribution supports bash 4.0 or older. (It depends on what is "major" though...)

The problem is macOS...

@sudotac
Copy link
Contributor Author

sudotac commented Dec 6, 2023

The problem is macOS...

Sorry, I confused it with macPorts. Then, this change will cause the same compatibility issue on macOS. It is necessary to check bash version.

@sudotac sudotac force-pushed the improve-bash-completion-with-compopt branch 5 times, most recently from de394a7 to 304ec9a Compare December 13, 2023 14:38
@sudotac sudotac force-pushed the improve-bash-completion-with-compopt branch from 304ec9a to 22bf919 Compare January 4, 2024 12:39
@sudotac
Copy link
Contributor Author

sudotac commented Jan 4, 2024

I found out we cannot add tests for 22bf919 for now because white spaces are trimmed by runtime.complete().

epage added a commit to epage/completest that referenced this pull request Jan 15, 2024
@epage
Copy link
Member

epage commented Jan 15, 2024

I found out we cannot add tests for 22bf919 for now because white spaces are trimmed by runtime.complete().

Resolved in #5310

@sudotac sudotac force-pushed the improve-bash-completion-with-compopt branch from 22bf919 to 31e023f Compare January 16, 2024 13:51
@sudotac
Copy link
Contributor Author

sudotac commented Jan 16, 2024

Thank you very much!
I've added a test for the remaining one.

@sudotac sudotac force-pushed the improve-bash-completion-with-compopt branch from 31e023f to 13a7980 Compare January 20, 2024 12:31
@epage
Copy link
Member

epage commented Jan 22, 2024

Thanks!

@epage epage merged commit 646134a into clap-rs:master Jan 22, 2024
22 checks passed
@sudotac sudotac deleted the improve-bash-completion-with-compopt branch January 25, 2024 14:45
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

Successfully merging this pull request may close these issues.

clap_complete: File path is completed too early in bash
2 participants