Update: July 26, 2019
This section of the forum is now closed; we are working on a new support model for WDL that we will share here shortly. For Cromwell-specific issues, see the Cromwell docs and post questions on Github.

restricting variable interpolation in command block to the shell?

bhaasbhaas Broad InstituteMember, Broadie

Hi

Is it possible to write the wdl command block in such a way that certain ${variables} can be set and defined during the command block execution and not by the wdl-runner?

eg.

  myvar=$(run some bash command)
  echo ${myvar}

  # where ${myvar} isn't going to be looked up and replaced by cromwell, but rather during the bash exec.

thanks!

Best Answer

  • ChrisLChrisL Cambridge, MA admin
    Accepted Answer

    @bhaas I see two potential problems here. First, the string ${ causes some problems in the bash script, since that's what WDL defines as the start of its interpolation escape. The closing } might also cause problems since that's what WDL defines as the end of the command block.

    • For the first problem (${), there's not really a nice answer. Until we come up with one, the best way might be to have Cromwell injecting the $ into the command rather than having it written in the command block.
    • The second problem (}) is easier to solve. Instead of having a command block with {...}, you can use <<<...>>>.

    Here's an example:

    task foo {
      String dollar = "$"
      command <<<
        myvar = $(run some bash)
        echo ${dollar}{myvar}
      >>>
    }
    

Answers

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

    @bhaas I see two potential problems here. First, the string ${ causes some problems in the bash script, since that's what WDL defines as the start of its interpolation escape. The closing } might also cause problems since that's what WDL defines as the end of the command block.

    • For the first problem (${), there's not really a nice answer. Until we come up with one, the best way might be to have Cromwell injecting the $ into the command rather than having it written in the command block.
    • The second problem (}) is easier to solve. Instead of having a command block with {...}, you can use <<<...>>>.

    Here's an example:

    task foo {
      String dollar = "$"
      command <<<
        myvar = $(run some bash)
        echo ${dollar}{myvar}
      >>>
    }
    
Sign In or Register to comment.