4

I have a script in GitLab CI but one command sometimes ends with exit code 101 what is OK in my use case and I want to ignore it.

I would use true:

failing_script || true

But it will ignore all exit codes, so I will not be notified when there will be some other error.

I would need something like this:

failing_script || (true only if exit code 101)
2
  • Do you need to exit with the original status if it is neither 0 nor 101? If so, then you have to work a bit harder than if it is sufficient to exit with a non-zero exit code (e.g. 1) when anything goes wrong. Commented Jan 12, 2020 at 7:00
  • Not necessary, @Frumpled answer is good enough and elegant. But it could be useful for others to know how to do it. Commented Jan 12, 2020 at 20:08

1 Answer 1

8

This seems to be what you're looking for:

failing_script|| [ $? -eq 101 ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.