I'm trying to do all these two functions at the same time,
xcodebuild || exit
and,
xcodebuild | tee xcodebuild.log | xcpretty
in a script file,
build.sh
Now I do it like this, but the last command 'exit' not work.
xcodebuild | tee xcodebuild.log | xcpretty || exit
I expect the command 'xcodebuild', not only can print logs to a file, but also can 'exit' my script file when it error.
If anyone could give me a hint in the right direction as to how should I do it would really be appreciated.
Updated It works for me:
xcodebuild | tee xcodebuild.log | xcpretty
if [ "${PIPESTATUS[0]}" != "0" ]; then
exit 1
fi
| - is pipe, so the output on the LHS becomes input of the RHS (LHS= left hand side of the symbol)
; - next command will run regardless of the exit status of the previous command
&& - means RHS command will execute ONLY if LHS has exit status of 0, which means success
|| - is the opposite of directly above
These above are all serial commands.
Paralell run is done with mpi, or at least threads
exit was not exiting because xcpretty was returning SUCCESS, even though you wanted to hang the condition to xcodebuild