The paradox of logical AND (&&) and OR (||) in a bash script to check the successful execution of command (exit code of 0 is interpreted as true)

So I well understand that exit code of 0 is considered success in running of a program. Then we use this in bash scripts with logical AND and OR to run the next program based on the exit status of the first program. A good example can be found here: https://unix.stackexchange.com/a/187148/454362

How do I capture the return status and use tee at the same time in korn shell?

Consider Source code: 1. Parent.sh #!/usr/bin/ksh # No tee ksh Child.sh; exit_status=$?; echo "Exit status: ${exit_status}" # Using tee ksh Child.sh | tee -a log.txt; exit_status=$?; echo "Exit status: ${exit_status}" 2. Child.sh #!/usr/bin/ksh … exit 1; Output: Exit status: 1 Exit status: 0 Variable $exit_status is capturing the exit status of Child.sh and so is … Read more