1

I have a GO application, which at some point executes os.Exit(1) because of an error that happens, the problem is that it is closing my terminal as well, not only terminating the app.

I am calling the application like this application --param1 1

How can I prevent that the application will not close my terminal and how can I get the exit status from it?

2
  • Have you set the errexit shell option in your shell before running the application? You should be able to check whether this option is set with set -o | grep errexit. If it's set, the shell would exit if the application returns a non-zero exit status.
    – Kusalananda
    Oct 2, 2020 at 10:18
  • 1
    You could also (probably) configure your terminal to not close when the command exits. With many terminal programs, this can be set in a different profile than your day-to-day usage. Oct 2, 2020 at 13:42

1 Answer 1

2

You probably have set errexit that makes shell exit whenever the command returns not zero exit status. You can disable this behavior with set +e command. Other thing that you can do is making bash or with true command. The invocation will look like:

application --param1 1 || true
1
  • 1
    Nail it. Actually, I was calling set -e. Thanks
    – lcssanches
    Oct 4, 2020 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .