You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Task file commands with pipe (|) in them don't fail #392
In my tests, the behavior of Bash and Task are the same: exit 1 | echo "Hello" prints "Hello" without failing.
Regarding pipefail, you have a typo there: set -e pipefail does nothing, it should be set -o pipefail. When you do that, it works fine in Task as well.
The only difference I found is that Bash support set -eo pipefail while Task doesn not understand -eo at all. If you think that is a bug, I recommend you to open an issue in the Bash interpreter library that Task uses: https://github.com/mvdan/sh . Feel free to ping me there and mention this issue if you want.
@andreynering can you explain why this only works for single line scripts? I used your provided workaround successfully with cmd1 but with cmd2 it continues execution
cmd1:
cmds:
- set -o pipefail ; aws something | jq .someField
- echo success # this never happens if aws failscmd2:
cmds:
- | set -e set -u set -o pipefail aws something | jq .someField echo success # happens despite error in the aws command
Is there a way to set -e; set -o pipefail for all cmd's?
I want the task to stop if any of the cmd's fail, currently I have to set the bash options in front of everyone of them like so:
cmd1:
cmds:
- set -e -o pipefail; do-something-1 | foo
- set -e -o pipefail; do-something-2 | bar
- set -e -o pipefail; do-something-3 | baz
It would be nice to have the possiblity to do the set -e -o pipefail once for all of them. I tried this:
cmd1:
cmds:
- set -e -o pipefail
- do-something-1 | foo
- do-something-2 | bar
- do-something-3 | baz
Activity
andreynering commentedon Dec 5, 2020
Hi @brodster2, thanks for opening this issue!
In my tests, the behavior of Bash and Task are the same:
exit 1 | echo "Hello"prints "Hello" without failing.Regarding
pipefail, you have a typo there:set -e pipefaildoes nothing, it should beset -o pipefail. When you do that, it works fine in Task as well.The only difference I found is that Bash support
set -eo pipefailwhile Task doesn not understand-eoat all. If you think that is a bug, I recommend you to open an issue in the Bash interpreter library that Task uses: https://github.com/mvdan/sh . Feel free to ping me there and mention this issue if you want.Hades32 commentedon May 30, 2022
@andreynering can you explain why this only works for single line scripts? I used your provided workaround successfully with
cmd1but withcmd2it continues executionghostsquad commentedon May 30, 2022
This is not a problem with Task directly. Please report https://github.com/mvdan/sh.
Notice also that there are other differences in your script, not just the lack of newline characters, but also the lack of semicolons.
This is definitely not a task specific problem though.
pinpox commentedon Nov 8, 2022
Is there a way to
set -e; set -o pipefailfor all cmd's?I want the task to stop if any of the cmd's fail, currently I have to set the bash options in front of everyone of them like so:
It would be nice to have the possiblity to do the
set -e -o pipefailonce for all of them. I tried this:But this seems to fully ignore the first cmd.