How do return codes (rc) for multiple commands in a task work?

shleeshlee CambridgeMember, Broadie ✭✭✭✭✭

This question came up during the July 2018 Cambridge workshop.


  • ChrisLChrisL Cambridge, MAMember, Broadie, Moderator, Dev admin

    If this means what I think it means...

    task oops {
      command <<<
        echo "a" > a
        echo "c" > c
        cat a
        cat b
        cat c

    The exit code from this script is 0 because the script as a whole would return 0 (the RC of the last command).

    I believe you can use set -e at the top of the script to force it to return immediately at the first error (in which case the return code would be 1)

  • shleeshlee CambridgeMember, Broadie ✭✭✭✭✭
Sign In or Register to comment.