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

There should be a way to exit with a non-zero exit code #5398

Open
TOGoS opened this issue Oct 8, 2024 · 0 comments
Open

There should be a way to exit with a non-zero exit code #5398

TOGoS opened this issue Oct 8, 2024 · 0 comments

Comments

@TOGoS
Copy link

TOGoS commented Oct 8, 2024

Is your feature request related to a problem? Please describe.

As far as I am aware, there is no way to have a Unison program exit with a specified exit code.

Describe the solution you'd like

My preference would be to have main-like functions return an integer, since that allows for composable mains (as opposed to something like an unhandleable IO.exit effect). Having a 'set exit code' or 'quit now with exit code' be part of the IO ability would also be acceptable. Or a special type of Failure. Or a new ability. Maybe call it Quit Int.

It is the kind of thing I often want to handle, though, because I don't necessarily want to force the OS process to quit. e.g. just because my program does an exit 1 doesn't mean I want ucm.exe to stop. What I want is not so much about stopping the process as providing an exit code from main, which if it happens to be the top-level function, should cause the containing process to exit with the code I gave.

/me grumbles about always writing wrapper functions to avoid writing System.exit(1)

Describe alternatives you've considered

Current workaround is to throw an exception. This doesn't allow for exit codes other than 0 (return normally) or 1 (throw exception), and results in Unison printing out some additional information that I didn't necessarily want to show.

Additional context

image

(from a little proof-of-concept program)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant