2016-10-07 8 views
1

일부 경로 이름에는 공백이있는 시스템이 있습니다. 그것들은 핵심 코드의 일부이기 때문에 으로 이름을 바꿀 수 없습니다. 명령 줄 명령을 호출하는 도구에서이를 처리하는 것은 큰 따옴표 세트를 추가하는 것일뿐입니다.xml 인터페이스 매개 변수 전달에서 공백 처리

그러나 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 [email protected]@$2; 
    </execute> 
</command> 

$ 1 = "foo는 바"과 $ 2 가정 = " \ main \ 1 "

첫 번째 매개 변수에 공백이 포함되어 있기 때문에 두 번째 매개 변수는 물론 무시됩니다.

Preparsing Command Set: [pushd cleartool desc [email protected]@$2], using Params: 'foo bar main\1'. 
Command Set Parsed To: [pushd cleartool desc "[email protected]@bar"] 

내가 호출 명령에 따옴표를 추가하여이 고정 시도 :

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

따옴표 명령에 그것을 만들지 만, 변화하지 않는 :

Preparsing Command Set: [pushd cleartool desc [email protected]@$2], using Params: '"foo bar" \main\1'. 
Command Set Parsed To: [pushd cleartool desc "[email protected]@bar"] 

을 시도를 해결책 : @@을 호출 명령으로 이동하고 수신 명령에서 제거하고 추가 매개 변수를 추가하십시오 (1 공간을 처리 할 수 ​​있도록) :

<run command="cc_describe" params="[email protected]@$2"/> 

<command name="cc_describe"> 
    <execute> 
     pushd cleartool desc $1$2$3; 
    </execute> 
</command> 

실행 결과 :

Preparsing Command Set: [pushd cleartool desc [email protected]@$2$3], using Params: 'foo bar \main\1'. 
Command Set Parsed To: [pushd cleartool desc "[email protected]@\main\1"] 

답변

1

@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" "[email protected]@$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> 
+1

또, 잘 했어! +1 – VonC

1

일반적으로이 매개 변수는 전체 따옴표 사이에 있어야한다 :

스크립트 계정에 파일 이름을 할 필요가있는 경우 다음
cleartool describe "foo [email protected]@\main\1" 

extended pathname , 해당 매개 변수를 두 부분으로 나누는 역할이 the @@ 부분입니다. 펄에 따라 "What is an Adaptor in Build Forge?"(the help page에서 PDF를) 읽은 후

, 대신 처음 두의 모든 매개 변수를 사용할 수 있는지 확인합니다.
호출은 $1$2 (나는뿐만 아니라 @@를 추가) 유지 : 당신이 본 것처럼, cc_describe 명령 블록에 $1$2은 때문에의 파일 이름의 일부를 나타낼 수

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

우주 문제.
$* (bash 스타일) 또는 join('', @ARGV) (perl 스타일) 중 하나를 사용하여 매개 변수를 연결해 봅니다 (숫자가 무엇이든간에).
매개 변수를 연결하면 공백이 포함 된 파일의 전체 확장 경로 이름으로 끝납니다.

+0

확장 된 경로 이름에는 공백이 포함되지 않으므로 파일 이름 만 큰 따옴표로 묶었습니다. 두 매개 변수를 연결하고 (호출 명령에 @@를 포함하는) 어댑터를 얻는 방법을 찾더라도 파일 이름에 공백이 있으면 cc_describe 블록에 전달 된 매개 변수 조각이 누락 될 수 있습니다. – Jozef

+1

@Jozef "두 매개 변수를 연결하고 (호출 명령에 @@를 포함하는) 어댑터를 얻는 방법을 찾으면"두 매개 변수를 연결하는 * 대답 * cc_describe 블록 내의 * 모든 매개 변수를 연결합니다. – VonC

+0

어댑터의 기능에는 연결 방법이 포함되어 있지 않습니다. 사용할 수있는 모든 명령의 위치 : http://www.ibm.com/support/knowledgecenter/SSB2MV_8.0.0/com.ibm.rational.buildforge.doc/topics/adaptor_xml__reference.html – Jozef