Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Differences between single line and multi line Batch Command #3557

mattpeters ·
Hi, we found this behavior and it caused some surprises.

Slashes within quotes, and batch commands such as echo, are handled differently in singleline and multiline Shell/Batch Command

We think the behavior should be changed to never delete the slashes and to always handle non-exe batch commands (as in the multiline case). It looks like the behavior was added to be syntactic sugar that makes single line shell/batch commands handle commands with spaces in them, but so far I haven’t thought of a way to implement that robustly.

We have a workaround (adding comments to make all Shell/Batch Command steps multiline).

With a batch script that takes up a single line:
[list]
Batch commands such as echo or rmdir are not valid (they give an “Unrecognized command” error)
[list]
Slashes within quotes remain untouched[/*:m]
Occurs on Quickbuild version 6.1.16, 2016-05-24, linux server with windows agent.[/*:m]
Linux agent + windows server may be unnecessary; I didn’t test on other configurations.[/*:m][/list:u]

Create a configuration with two variables and two steps:

[list]
Name: clExeSingleSlashes[/*:m]
Variable 2:
[list]
Value: c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe\[/*:m][/list:u][/*:m]
Serial Composition Step [/*:m]
Step 2:
[list]
Build -> Shell/Batch Command step[/*:m]
Single slashes not in quotes are not stripped
[list]
c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe[/*:m][/list:u][/*:m]
07:25:43,108 DEBUG - Executing command: c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe[/*:m][/list:u][/*:m][/list:u]
[/*:m]
Command:
[list]
Output:
[list]
Single slashes in quotes on a command with multiple lines are not stripped
[list]
::multiline[/*:m]
Output:
[list]
::multiline[/*:m]
Single slashes not in quotes, single line
[list]
${vars.getValue('clExeSingleSlashes')}[/*:m][/list:u][/*:m]
Executing Command: c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe[/*:m][/list:u][/*:m][/list:u]
[/*:m]
Command:
[list]
Output:
[list]
Single slashes in quotes, multiline
[list]
:: multiline[/*:m]
Output:
[list]
:: multiline[/*:m]
Single slashes in quotes, multiline (comment making it multiline is the second line rather than the first)
[list]
"${vars.getValue('clExeSingleSlashes')}"[/*:m]
Output:
[list]
"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe"[/*:m]
Double slashes, in quotes, multiline
[list]
:: multiline[/*:m]
Output:
[list]
:: multiline[/*:m]
Double slashes in quotes, singleline
[list]
"${vars.getValue('clExeDoubleSlashes')}" [/*:m][/list:u][/*:m]
07:15:51,542 DEBUG - Executing Command: "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe\"[/*:m][/list:u][/*:m][/list:u]
[/*:m]
Command:
[list]
Output:
[list]
07:18:37,318 WARN - cl : Command line warning D9024 : unrecognized source file type 'foo', object file assumed[/*:m][/list:u][/*:m][/list:u]
[/*:m]
Command:
[list]
${vars.getValue('clExeSingleSlashes')} foo[/*:m][/list:u][/*:m]
07:20:14,708 DEBUG - Executing Command:[/*:m]
c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe foo[/*:m]
07:20:14,725 WARN - 'c:\Program' is not recognized as an internal or external command,[/*:m]
[*]07:20:14,725 WARN - operable program or batch file.[/*:m][/list:u][/*:m][/list:u][/*:m][/list:u]
  • replies 1
  • views 3112
  • stars 0
robinshen ADMIN ·
Make sure to turn off the legacy command mode in advanced setting of the configuration, then they will behave the same. Some history:
QB initially supports single line command only and the command is submitted to JVM command execution facility, and it will strips backslash and does not recognize shell specific commands and operations such as echo, pipeline, redirection. Then we have the requirement of supporting multiple line commands, and that was supported by wrapping the command inside a batch. Lately we found that the inconsistency between single line and multi-line is confusing, so wrap the single line execution into a batch either. But to add backward compatibility a special flag is added as "legacy command mode".