Q
Q
q2zoff2019-01-29 18:34:55
bash
q2zoff, 2019-01-29 18:34:55

How to determine if there is an error in a process group (pipeline)?

Hello.
Let's say that in the pipeline:
prog1 | prog2 | prog3
an error occurred in prog2.
How to get a return code? Is it a variable $? contains the return code of the last command (prog3 in this case).
In particular, I need to somehow make sure that the commands through the pipeline are executed without errors. After that, the execution of the underlying code will become possible.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitsliputsli, 2019-01-29
@q27off

Use set -o pipefail in front of the container

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question