【发布时间】:2016-10-07 20:26:22
【问题描述】:
我们有一个系统,它的某些路径名中包含空格。由于它们是核心代码的一部分,它们不能重命名。在调用命令行命令的工具中处理这个问题只是添加双引号集。
但是,我还没有在 Build Forge 适配器使用的 xml 代码中找到解决此问题的方法。
例如,当尝试让适配器执行以下命令时:
cleartool describe "foo bar"@@\main\1
代码如下:
<match pattern="^(.*?)\@\@(.*?)$">
<run command="cc_describe" params="$1 $2"/>
<command name="cc_describe">
<execute>
pushd cleartool desc $1@@$2;
</execute>
</command>
假设 $1 = "foo bar" 和 $2 = "\main\1"
在执行时,第二个参数 - 当然 - 会被忽略,因为第一个参数包含一个空格:
Preparsing Command Set: [pushd cleartool desc $1@@$2], using Params: 'foo bar main\1'.
Command Set Parsed To: [pushd cleartool desc "foo@@bar"]
我尝试通过在调用命令中添加双引号来解决此问题:
<run command="cc_describe" params=""$1" $2"/>
双引号使其进入命令,但没有区别:
Preparsing Command Set: [pushd cleartool desc $1@@$2], using Params: '"foo bar" \main\1'.
Command Set Parsed To: [pushd cleartool desc "foo@@bar"]
尝试的解决方案:将@@移动到调用命令,将其从接收命令中删除并添加附加参数(以便能够处理1个空格):
<run command="cc_describe" params="$1@@$2"/>
<command name="cc_describe">
<execute>
pushd cleartool desc $1$2$3;
</execute>
</command>
执行结果:
Preparsing Command Set: [pushd cleartool desc $1@@$2$3], using Params: 'foo bar \main\1'.
Command Set Parsed To: [pushd cleartool desc "foobar@@\main\1"]
【问题讨论】:
标签: xml clearcase buildforge