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

shleeshlee CambridgeMember, Administrator, Broadie, Moderator admin

This question came up during the July 2018 Cambridge workshop.

Answers

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

    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, Administrator, Broadie, Moderator admin
Sign In or Register to comment.