Email or username:

Password:

Forgot your password?
7 comments
Adam Katz :donor:

@b0rk_reruns @b0rk grep won't succeed in that example unless curl's standard output matches that pattern, which is unlikely if curl failed. However, without pipefail or referencing ${PIPESTATUS[0]} for curl's exit code, you won't know if curl failed or if its lack of pandas caused grep to fail.

Jargoggles

@b0rk_reruns
You can also use && to specify that you need both pieces to execute properly.

So you can do unzip fle.zip && cat file1 and if it can't unzip that file because it doesn't exist, then it won't run that cat command.

LisPi
@b0rk_reruns @indigoparadox There are some added rules about conditional dispatch for set -e, but they themselves perserve the general hackiness of bash.
Johannes Schnatterer

@b0rk_reruns
I use
set -o errexit -o nounset -o pipefail
Because it is easier to understand.
Also, it took me ages to remember which option is which option is which and `set -eu` is not very intuitive.

patter

@b0rk_reruns if you're scripting rather than tapping raw bash into the terminal, this should give the same behaviour

"#!/bin/bash -e -u -o"

Zack Weinberg

@patterfloof @b0rk_reruns No, you can only put one option on a #! line. I'm not sure whether the kernel will ignore the second two options or whether it will pass "-e -u -o" to bash as a single argv element with internal spaces, but either way it won't do what you wanted.

Go Up