Closed charleso closed 9 years ago
I'm on the fence with that one. On one hand it is good to have the error codes. On the other hand, having them in runOrFail
rather than in PirateMain
means that runOrFail
is really, really unsafe to call anywhere else than in main
which is not enforced.
I'm on the fence with that one. On one hand it is good to have the error codes. On the other hand, having them in runOrFail rather than in PirateMain means that runOrFail is really, really unsafe to call anywhere else than in main which is not enforced.
That was my first reaction too. It's either this or IO[Option[A]]
or something. Right now the errors are being swallowed.
@charleso @etorreborre I am not sure I am following this correctly - but having written it, the only purpose of Runner is to run a program to the end, it not setting exit codes is a really really bad bug from my perspective. It is pretty much it's one and only job. Forcing use of PirateMain/PirateMainIO isn't feasable, Runner is meant to be the top level, those are just conveniences. I am a little concerned about the non termination related code in here, but I don't see how you can not be terminating.
I think it's ok but maybe it is worth mentioning in the comments somewhere that the program will exit after that and not just have a side-effect on the console.
@etorreborre @charleso I don't particularly mind how it is done, but it does have to call sys.exit at some point. My preference would be for this to return to being about 5 lines of code rather than 50, and I would like there to be pure versions that have the type IO[ExitStatus], but I really want there to a single call that just does the right thing. Just look through all of our code, the number of programs that don't set error codes is horrifying.
@markhibberd @etorreborre Let me know if that looks better.
@markhibberd https://github.com/markhibberd @etorreborre https://github.com/etorreborre Let me know if that looks better.
LGTM :100:
That's great! Thanks @charleso.
My bad, I told @FrontierOtr that we shouldn't be doing this, but as it stands this function is possible to use and will make it impossible to return the correct exit code.