version: '2'
tasks:
  default:
    vars:
      MULTILINE: "\n\nfoo\n  bar\nfoobar\n\nbaz\n\n"
    cmds:
      - task: file
        vars:
          CONTENT:
            sh: "echo 'foo\nbar'"
          FILE: "echo_foobar.txt"
      - task: file
        vars:
          CONTENT:
            sh: "echo -n 'foo\nbar'"
          FILE: "echo_n_foobar.txt"
      - task: file
        vars:
          CONTENT:
            sh: echo -n "{{.MULTILINE}}"
          FILE: "echo_n_multiline.txt"
      - task: file
        vars:
          CONTENT: "{{.MULTILINE}}"
          FILE: "var_multiline.txt"
      - task: file
        vars:
          CONTENT: "{{.MULTILINE | catLines}}"
          FILE: "var_catlines.txt"
      - task: enumfile
        vars:
          LINES: "{{.MULTILINE}}"
          FILE: "var_enumfile.txt"
  file:
    cmds:
      - |
        cat << EOF > '{{.FILE}}'
        {{.CONTENT}}
        EOF
  enumfile:
    cmds:
      - |
        cat << EOF > '{{.FILE}}'
        {{range $i, $line := .LINES| splitLines}}{{$i}}:{{$line}}
        {{end}}EOF
