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

Don't close standard file handlers #23

Conversation

SteveBarnegren
Copy link
Contributor

When 'shelling out' to an async operation, FileHandler.standardOutput can be passed in to see the output in realtime, in the same way as if the command had been executed in the Terminal:

try shellOut(to: "pod repo update", outputHandle: FileHandle.standardOutput)

ShellOut currently calls closeFile() on the passed in output handler and error handler. In the case that one of the 'standard' handlers has been passed in, this causes issues such as print() not working.

This PR checks for the 3 standard handlers (input, output, error) and bypasses the call to closeFile(). Any other passed in FileHandler will receive the call.

@JohnSundell let me know how you feel about this solution. It does add a special casing for the 3 handlers (which is a bit weird), but the advantage is that there's no additional complexity to the api, which is probably a good thing for a scripting library!

Copy link
Owner

@JohnSundell JohnSundell left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this @SteveBarnegren, and sorry for taking so long to merge it in 😅

@JohnSundell JohnSundell merged commit 4ebf258 into JohnSundell:master Dec 12, 2019
@SteveBarnegren
Copy link
Contributor Author

Hey @JohnSundell. No problem, it's nice to finally get it merged in! 👍

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 this pull request may close these issues.

2 participants