tldr-pages / tldr-python-client

:snake: Python command-line client for tldr pages 📚
https://pypi.org/project/tldr/
MIT License
599 stars 95 forks source link

Autocomplete not working on macOS #194

Closed stevejbrown closed 1 year ago

stevejbrown commented 2 years ago

I get the error (eval):1: bad pattern: [head, when trying to autocomplete tldr pages using zsh on macOS. I assume bash will have a similar error. This is because the BSD version of sed (default on macOS) doesn't support the non-word \W regular expression extension that is used in the create_parser function. As a result, non-word characters aren't stripped from the list of tldr pages generated for the completion script and the script generates an error when attempting to autocomplete.

Replacing \W with either the POSIX compliant [^[:alnum:]_] or [^a-zA-Z0-9_] solved the problem for me and should work across GNU and BSD platforms. If you would like, I can open a pull request with the change.

Thanks for providing this client!

owenvoke commented 2 years ago

I think it'd be easiest to open a PR and resolve this, or alternatively have a dependency on gnu-sed on macOS (e.g. via Brew)