diff --git a/CommandLineTool.yml b/CommandLineTool.yml index c03634ec..c57db61d 100644 --- a/CommandLineTool.yml +++ b/CommandLineTool.yml @@ -567,6 +567,10 @@ $graph: stdout: random_stdout_filenameABCDEFG ``` + If the `CommandLineTool` contains logically chained commands + (e.g. `echo a && echo b`) `stdout` must include the output of + every command. + - name: stderr type: enum @@ -700,6 +704,10 @@ $graph: Capture the command's standard output stream to a file written to the designated output directory. + If the `CommandLineTool` contains logically chained commands + (e.g. `echo a && echo b`) `stdout` must include the output of + every command. + If `stdout` is a string, it specifies the file name to use. If `stdout` is an expression, the expression is evaluated and must @@ -1105,8 +1113,8 @@ $graph: extends: ProcessRequirement doc: | Modify the behavior of CommandLineTool to generate a single string - containing a shell command line. Each item in the argument list must be - joined into a string separated by single spaces and quoted to prevent + containing a shell command line. Each item in the `arguments` list must + be joined into a string separated by single spaces and quoted to prevent intepretation by the shell, unless `CommandLineBinding` for that argument contains `shellQuote: false`. If `shellQuote: false` is specified, the argument is joined into the command string without quoting, which allows diff --git a/conformance_tests.yaml b/conformance_tests.yaml index 57857c15..ed3b4854 100644 --- a/conformance_tests.yaml +++ b/conformance_tests.yaml @@ -3540,3 +3540,16 @@ doc: | Use of $(runtime.outdir) for outputBinding glob. tags: [ required, command_line_tool ] + +- label: stdout_chained_commands + output: { + "out": "a\nb\n" + } + tool: tests/stdout_chained_commands.cwl + doc: | + Test that chaining two echo calls causes the workflow tool to emit the output to stdout. + This is to confirm that the workflow tool will **not** create an expression such as + `echo a && echo b > out.txt`, but instead will produce the correct `echo a && echo b`, + and capture the output correctly. + tags: [ shell_command, command_line_tool ] + diff --git a/invocation.md b/invocation.md index f9b7040a..d5302914 100644 --- a/invocation.md +++ b/invocation.md @@ -132,7 +132,11 @@ Once the command line is built and the runtime environment is created, the actual tool is executed. The standard error stream and standard output stream may be captured by -platform logging facilities for storage and reporting. +platform logging facilities for storage and reporting. If there are multiple +commands logically chained (e.g. `echo a && echo b`) implementations must +capture the output of all the commands, and not only the output of the last +command (i.e. the following is incorrect `echo a && echo b > captured`, +as the output of `echo a` is not included in `captured`). Tools may be multithreaded or spawn child processes; however, when the parent process exits, the tool is considered finished regardless of whether diff --git a/tests/stdout_chained_commands.cwl b/tests/stdout_chained_commands.cwl new file mode 100644 index 00000000..b0cf25db --- /dev/null +++ b/tests/stdout_chained_commands.cwl @@ -0,0 +1,19 @@ +cwlVersion: v1.2 +class: CommandLineTool +requirements: + - class: ShellCommandRequirement +inputs: [] +outputs: + out: + type: string + outputBinding: + glob: out.txt + loadContents: true + outputEval: $(self[0].contents) +stdout: out.txt +arguments: + - echo + - a + - {valueFrom: '&&', shellQuote: false} + - echo + - b