1

I have the following script:

{
   ...
   many commands and printing
   ...
   if something goes wrong I do exit 1
} 2>&1 | tee test.log

But the problem is that the {} block is exiting and not the whole script.

How can I make the whole script exit?

1 Answer 1

1

Add the following line after your tee command:

test ${PIPESTATUS[0]} -eq 0 || exit ${PIPESTATUS[0]}

Reference Link: https://stackoverflow.com/a/34386000/2357256

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.