-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
interp: Return invalid globs when nullglob is set #862
Conversation
I'm a bit confused by your commit message: |
Sorry, I didn't mean to make the example confusing, the invalid glob is the first opening of the test expression,
because with nullglob enabled the current code does not append the invalid glob, so the opening bracket is removed from the expression. |
Ah, I see, thanks for the clarification. Do we need to add InvalidGlobError? It's the only error that the method ever returns, so we can avoid extending the API and simply use Otherwise the change sounds good to me! |
Err, scratch that. I hadn't noticed that the call is to the |
I also considered having the glob function return nil, nil when the glob is invalid and then having the caller differentiate between a nil slice and an empty slice. That method worked, but it seemed a little too clever and brittle. |
Yeah, I agree that's too subtle - I don't like APIs that give different meanings to nil vs empty. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM with a naming nit
Prior to this commit invalid globs were returned as null when nullglob was set, which resulted in test expressions failing: $ shopt -s nullglob; [ -n butter ] && echo bubbles "-n": executable file not found in $PATH After this commit invalid globs are returned verbatim when nullglob is set.
Thanks for the careful review @mvdan, I believe this is now ready to merge. |
Thanks to you! |
Prior to this commit invalid globs were returned as null when nullglob
was set, which resulted in test expressions failing:
$ shopt -s nullglob; [ -n butter ] && echo bubbles
"-n": executable file not found in $PATH
After this commit invalid globs are returned verbatim when nullglob is
set.