Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 通过ANT将值附加到shell脚本中的属性_String_Shell_Ant - Fatal编程技术网

String 通过ANT将值附加到shell脚本中的属性

String 通过ANT将值附加到shell脚本中的属性,string,shell,ant,String,Shell,Ant,需要一些关于ant和shell脚本的帮助。 我需要打开一个shell脚本,并使用ant将一些值附加到shell脚本的属性中 <property name="args" value="${ARGS}"/> <replaceregexp file="abc.sh" match="ARGS=(.*)" replace="ARGS=${args} some_value=true" byline="true" flags="i" /> 下面是我使用ant编写的

需要一些关于ant和shell脚本的帮助。 我需要打开一个shell脚本,并使用ant将一些值附加到shell脚本的属性中

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />
下面是我使用ant编写的代码-

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />

我面临的问题是abc中ARGS的值。sh的格式为ARGS=“value”

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />
这段代码的输出是- ARGS=“value”某些值=真

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />
预期产量为- ARGS=“value some\u value=true”

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />

请帮帮我。

据我所知,你可以用
来得到你想要的东西。不需要
${args}
${args}
属性

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />
在XML中,属性值可以由引号(
)或单引号(
)包围。在以下示例中

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />
match="..."
replace="..."
…变成

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />
match='...'
replace='...'
引号已替换为单引号。使用单引号可以方便地在
匹配
替换
属性中使用引号:

<property name="args" value="${ARGS}"/>         
<replaceregexp file="abc.sh"
match="ARGS=(.*)"
replace="ARGS=${args} some_value=true" 
byline="true"
flags="i" />
替换abc.sh