Complete the code to enable the pipefail option in bash.
set [1] pipefailThe set -o pipefail command enables the pipefail option, which causes a pipeline to return the exit status of the last command to fail.
Complete the code to check if pipefail is enabled in the current shell.
shopt [1] pipefailThe shopt -o pipefail command shows if the pipefail option is set or not.
Fix the error in the code to enable pipefail correctly.
set [1] pipefailThe correct flag to enable pipefail is '-o'. Using '-e' or others will not enable pipefail.
Fill both blanks to create a pipeline that fails if any command fails, using pipefail.
set [1] pipefail cat file.txt | grep 'hello' | [2]
First, enable pipefail with set -o pipefail. Then, the pipeline ends with wc -l to count lines matching 'hello'.
Fill all three blanks to create a script that enables pipefail, runs a pipeline, and checks the exit status.
set [1] pipefail output=$(cat file.txt | grep 'error' | [2]) if [[ $? [3] 0 ]]; then echo "Success"; else echo "Failure"; fi
Enable pipefail with set -o pipefail. Use wc -l to count lines with 'error'. Then check if exit status equals zero with ==.