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

replace all non-word characters with wordify #166

Merged

Conversation

dustinlagoy
Copy link
Contributor

Use the regular expression set \W to replace all non-word characters instead of the fixed set [-.\s:] in wordify. I also added a test for subcommands containing slashes in their name as an example. This could be tested more robustly, though that would require more knowledge of some shell completion internals than I currently have.

Closes #165

Use the regular expression set \W to replace all non-word characters
instead of the fixed set [-.\s:] in wordify. Add a test for subcommands
containing slashes in their name as an example. This could be tested
more robustly.
@dustinlagoy
Copy link
Contributor Author

Actually I just noticed this does not work in bash (though does in zsh) for commands with slashes in them, as noted in #165. I'm not yet sure if this is something that could be fixed in the generated bash completion script or is a limit of bash itself.

@dustinlagoy
Copy link
Contributor Author

It looks like the weird command issue I was seeing was due to a conflict with the -o filenames option of the bash complete builtin. That probably reflects more on a poor design choice of using slashes in command names. In any case with this pull request the generated completion script does seem to be valid and works as expected if the -o filenames option is removed. I think this pull request is still worth merging as it will avoid generating incorrect completion code, though in cases like mine may lead to unexpected behavior.

tests/test_shtab.py Outdated Show resolved Hide resolved
shtab/__init__.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Mar 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.88%. Comparing base (2be59e4) to head (47e8401).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #166   +/-   ##
=======================================
  Coverage   88.88%   88.88%           
=======================================
  Files           3        3           
  Lines         360      360           
=======================================
  Hits          320      320           
  Misses         40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@casperdcl casperdcl merged commit c65c362 into iterative:main Mar 7, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could replace more non-word characters
2 participants