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

regular expression inside zsh-completion script needs adjustments #356

Open
0x17de opened this issue May 16, 2019 · 2 comments · May be fixed by #357
Open

regular expression inside zsh-completion script needs adjustments #356

0x17de opened this issue May 16, 2019 · 2 comments · May be fixed by #357

Comments

@0x17de
Copy link

0x17de commented May 16, 2019

Example line: https://github.com/pimutils/todoman/blob/master/contrib/completion/zsh/_todo#L46
containing: s/^[^#]\s*path\s*=\s*\(.*\)$/\1/p
requires the string to start with any character but # followed by any amount of spaces, followed by path and so on.

To currently make it work one has to make the configuration lines start with a whitespace for the regular expression to match, since [^#] requires any character but #.

There are more similar regular expressions below.

@WhyNotHugo
Copy link
Member

Yeah, it should probably be:

s/^\s*path\s*=\s*\(.*\)$/\1/p

I used these inputs as test:

 path=/opt
path = /opt
path  =  /opt
#path=/opt
 #path=/opt
# path=/opt
#path = /opt
# path= /opt

@doronbehar Your wrote these originally, can you confirm that this change would make sense?

@doronbehar
Copy link
Contributor

Boy that was a long time ago! I guess your request makes sense. However, After being more acquainted with writing ZSH completions ever since, looking back at what I wrote, I feel there's so much room for improvements in this one which I never would have thought of at the time due to my lack of experience back then.

As a start, I'll ditch the use of external tools such as sed and grep and use ZSH's very extensive Parameter Expansion features to achieve the same results. You can fix that for now if you wish but I'll start now on a larger refinement which may take me a few hours or the whole weekend if I won't find time..

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 a pull request may close this issue.

3 participants