xml接口参数传递中的句柄空间

xml接口参数传递中的句柄空间,xml,clearcase,buildforge,Xml,Clearcase,Buildforge,我们有一个系统,它的一些路径名中包含空格。由于它们是核心代码的一部分,因此不能重命名它们。在调用命令行命令的工具中处理这个问题只需要添加一组双引号 然而,在Build Forge适配器所使用的xml代码中,我还没有找到一种方法来处理这个问题 例如,当试图让适配器执行以下命令时: cleartool describe "foo bar"@@\main\1 <run command="cc_describe" params="&quot;$1&quot; $2"/>

我们有一个系统,它的一些路径名中包含空格。由于它们是核心代码的一部分,因此不能重命名它们。在调用命令行命令的工具中处理这个问题只需要添加一组双引号

然而,在Build Forge适配器所使用的xml代码中,我还没有找到一种方法来处理这个问题

例如,当试图让适配器执行以下命令时:

cleartool describe "foo bar"@@\main\1
<run command="cc_describe" params="&quot;$1&quot; $2"/>
该守则要求:

<match pattern="^(.*?)\@\@(.*?)$"> 

<run command="cc_describe" params="$1 $2"/>

<command name="cc_describe">
    <execute>
         pushd cleartool desc $1@@$2;
    </execute>
</command>
我尝试通过在调用命令中添加双引号来修复此问题:

cleartool describe "foo bar"@@\main\1
<run command="cc_describe" params="&quot;$1&quot; $2"/>
尝试的解决方案:将@@移动到调用命令,将其从接收命令中删除,并添加其他参数(以便能够处理1个空格):


通常情况下,参数应全部位于引号之间:

cleartool describe "foo bar@@\main\1"
然后,如果您的脚本需要考虑文件名和,那么它的角色就是将该参数在
部分周围分成两部分

在基于perl阅读“”(pdf,from)之后,检查是否可以使用所有参数而不是前两个参数。
通话仍然是
$1
$2
(我也会添加
@
):


如您所见,在
cc\u descripe
命令块中,
$1
$2
由于空格问题,只能表示文件名的一部分。
尝试并查看是否使用
$*
(bash样式)或
join(“”,@ARGV)
(perl样式)连接参数(无论其编号如何)。

连接参数后,返回文件的完整扩展路径名,并包含空格。

我使用@VonC建议使其工作。这是一种迂回的方法,但确实有效!仍然需要对其进行一些改进(例如不使用相同的临时文件)

以下是Build Forge ClearCase代码更改适配器的相关部分

<run command="cc_changes" params="$LAST_RUN $DEV_VIEW $VOB_TAG $DEV_STREAM" server="" dir="/" timeout="720"/>

<command name="cc_changes">
    <execute>
        cleartool startview $2
        cleartool mount $3
        <!-- Store the output of the find command in a text file -->
        pushd \\view${DirSep}$2 &amp;&amp; cleartool find .$3 -all -cview -version "{created_since($1)" -print &gt; %temp%\changes.txt
    <!-- Change each space to a = -->
    perl -pi~ -e "s/ /=/g" %temp%\changes.txt
    type %temp%\changes.txt
    </execute>
    <!-- Loop through the results and call the cc_describe command for each entry -->
    <resultsblock>
        <match pattern="^(.*?)\@\@(.*?)$">
            <run command="cc_describe" params="${DEV_VIEW} $1 $2" server="" dir="/" timeout="720"/>
        </match>
    </resultsblock>
</command>

<command name="cc_describe">
    <execute>
        <!-- Store the cleartool subcommand and the file name in a text file --> 
        echo desc -fmt "${ExpVar}En:${ExpVar}Vn:${ExpVar}Nd:${ExpVar}u:${ExpVar}c" "$2@@$3" &gt; %temp%\change.txt
        <!-- Change the =s back to spaces -->
        perl -pi~ -e "s/=/ /g"  %temp%\change.txt
        <!-- Pipe the text file into the cleartool command -->
        pushd \\view${DirSep}$1 &amp;&amp; cleartool &lt; %temp%\change.txt
    </execute>
    <resultsblock>
        <!-- For each match in the output, we add information to the BOM -->
        <match pattern="^(.*?):(.*?):(.*?):(.*?):(.*?)$">
            <bom category="Source" section="changes">
                <field name="file" text="$1"/>
                <field name="version" text="$2"/>
                <field name="date" text="$3"/>
                <field name="user" text="$4"/>
                <field name="comment" text="$5"/>
            </bom>
            <adduser group="MyChangers" user="${NOTIFICATION_GROUP}"/>
            <setenv name="Changes" value="$4 - $1&lt;br/&gt;" type="temp append"/>
        </match>
    </resultsblock>
 </command>

cleartool startview$2
ClearToolMount$3
pushd\\view${DirSep}$2&&;cleartool find.$3-all-cview-version“{created_-since($1)”-打印%temp%\changes.txt
perl-pi~-e“s/=/g”%temp%\changes.txt
键入%temp%\changes.txt
echo desc-fmt“${ExpVar}En:${ExpVar}Vn:${ExpVar}Nd:${ExpVar}u:${ExpVar}c”“$2@@@3”%temp%\change.txt
perl-pi~-e“s///g”%temp%\change.txt
pushd\\view${DirSep}$1&;cleartool%temp%\change.txt

扩展路径名从不包含空格,因此我只在文件名周围加了双引号。即使我能找到一种方法让适配器连接两个参数(并在调用命令中包含@),当文件名包含空格时,cc_descripe块仍然会丢失传递的参数。@Jozef“如果我想办法让适配器连接这两个参数(并在调用命令中包含@@)”":如果不是连接两个参数,而是连接cc_descripe块中的所有参数,则答案的全部要点。适配器的功能不包括连接方法。所有可用命令的Lsit:@Jozef Ids是否有可能将完整参数字符串写入文件,并从命令读取该文件block?(我正在尝试另一种方法)@Jozef当然,你可以发布(并接受)你自己的答案:这将有利于他人。
cleartool describe "foo bar@@\main\1"
<run command="cc_describe" params="$1 @@ $2"/>
<run command="cc_changes" params="$LAST_RUN $DEV_VIEW $VOB_TAG $DEV_STREAM" server="" dir="/" timeout="720"/>

<command name="cc_changes">
    <execute>
        cleartool startview $2
        cleartool mount $3
        <!-- Store the output of the find command in a text file -->
        pushd \\view${DirSep}$2 &amp;&amp; cleartool find .$3 -all -cview -version "{created_since($1)" -print &gt; %temp%\changes.txt
    <!-- Change each space to a = -->
    perl -pi~ -e "s/ /=/g" %temp%\changes.txt
    type %temp%\changes.txt
    </execute>
    <!-- Loop through the results and call the cc_describe command for each entry -->
    <resultsblock>
        <match pattern="^(.*?)\@\@(.*?)$">
            <run command="cc_describe" params="${DEV_VIEW} $1 $2" server="" dir="/" timeout="720"/>
        </match>
    </resultsblock>
</command>

<command name="cc_describe">
    <execute>
        <!-- Store the cleartool subcommand and the file name in a text file --> 
        echo desc -fmt "${ExpVar}En:${ExpVar}Vn:${ExpVar}Nd:${ExpVar}u:${ExpVar}c" "$2@@$3" &gt; %temp%\change.txt
        <!-- Change the =s back to spaces -->
        perl -pi~ -e "s/=/ /g"  %temp%\change.txt
        <!-- Pipe the text file into the cleartool command -->
        pushd \\view${DirSep}$1 &amp;&amp; cleartool &lt; %temp%\change.txt
    </execute>
    <resultsblock>
        <!-- For each match in the output, we add information to the BOM -->
        <match pattern="^(.*?):(.*?):(.*?):(.*?):(.*?)$">
            <bom category="Source" section="changes">
                <field name="file" text="$1"/>
                <field name="version" text="$2"/>
                <field name="date" text="$3"/>
                <field name="user" text="$4"/>
                <field name="comment" text="$5"/>
            </bom>
            <adduser group="MyChangers" user="${NOTIFICATION_GROUP}"/>
            <setenv name="Changes" value="$4 - $1&lt;br/&gt;" type="temp append"/>
        </match>
    </resultsblock>
 </command>