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

Fix portmaster completions when there are no matches #3950

Closed
wants to merge 1 commit into from

Conversation

asomers
Copy link
Contributor

@asomers asomers commented Apr 11, 2017

Don't spew warnings when there are no matches. Also, use the string
builtin instead of calling sed.

Fixes #3949

TODOs:

  • [N/A] Changes to fish usage are reflected in user documentation/manpages.
  • [N/A] Tests have been added for regressions fixed
  • [N/A] User-visible changes noted in CHANGELOG.md

Don't spew warnings when there are no matches.  Also, use the string
builtin instead of calling sed.

Fixes fish-shell#3949
@@ -48,8 +48,7 @@ complete -c portmaster -l version --description 'display the version number El E
# Grab items from the ports directory, max depth 2
complete -c portmaster -f --description 'Ports Directory' -a "
(
ls -d /usr/ports/(commandline -ct)*/ \
| sed -E -e 's#/usr/ports/##' -e 's#/+#/#' -e 's#([^/]+/[^/]+).*#\1#'
string match -r '(?<=/usr/ports/)[^/]*(?:/[^/]*)?' (__fish_complete_directories /usr/ports/(commandline -ct))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of PCRE features. Note that the (__fish_complete_directories /usr/ports/(commandline -ct)) does expand past two levels. Your PCRE ensures that only the first two levels are emitted by the completion. It's probably not worthwhile optimizing this any further. I just wanted to make sure you were aware that levels three and higher are expanded by __fish_complete_directories before being trimmed to two levels by the string match.

@krader1961 krader1961 added the bug Something that's not working as intended label Apr 11, 2017
@krader1961 krader1961 added this to the 2.6.0 milestone Apr 11, 2017
@krader1961
Copy link
Contributor

I went ahead and merged this as commit ed6298a because it is likely @asomers knew about the behavior of __fish_complete_directories and deemed any additional optimization not worth the effort.

@krader1961 krader1961 closed this Apr 11, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

portmaster completions spew errors if there are no matches
2 participants