-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
ListFiles()
Produces an Unwanted Newline Character When Zero Files Are Matched
#110
Comments
ListFiles()
Produces an Unwanted Newline CharacterListFiles()
Produces an Unwanted Newline Character When Zero Files Are Matched
Thanks, @relloyd! Arguably, this is a bug in |
probably don't want to return new lines here if the string is empty right? |
I wouldn't mind opening a PR for this if there isn't one :) I'm rather new to go so this is a perfect learning opportunity for me |
Absolutely, @hsheikhali1. Please do! |
Okay I was finally able to sit down and do some work for this :) I should have an PR soon |
So @bitfield - I have a newbie question lol. What's the best approach to testing my implementation of this fix? |
That's a very good question @hsheikhali1! Maybe one way to approach this is to ask "When my code is correct, what behaviour would users see from their programs?" We might answer that by saying, for example, "Calling Slice on a pipe with no data will produce a slice with zero elements". When you phrase it that way, it's relatively easy to imagine translating this into the form of a Go test, isn't it? And we'd want to see that with the current version of We can also imagine, though, a malicious implementation of |
For more context I've already written what I think the solution should look BUT this answer you've given has got me thinking. Thank you so much for the insightful comments |
I opened a PR after making quite some changes to the |
@bitfield What's the status of this? Does it still need to be fixed? |
I think I rather dropped the ball here on #110. Could you please review the situation and see where we are? I certainly think |
Yes, #115 is what I meant, sorry. Would you like to take a look at it and bring it up to date and address any outstanding comments? Alternatively, implement it from scratch if you prefer. |
In the following example pipe, if the glob matches zero files, then a single empty line is supplied to
ExecForEach()
, which causes therm
command to error:Can
ListFiles()
only produce an output if files are matched?There is a rather ugly workaround that filters blank lines as follows:
The text was updated successfully, but these errors were encountered: