Shell 使用sed为travis构建配置文件
我试图通过在末尾添加一个条目来更改php配置文件,以便通过添加sqlite文件路径来允许travis构建:Shell 使用sed为travis构建配置文件,shell,sed,travis-ci,Shell,Sed,Travis Ci,我试图通过在末尾添加一个条目来更改php配置文件,以便通过添加sqlite文件路径来允许travis构建: sh -c "if [ '$DB' = 'sqlite' ]; then sed -i "s/\?>/\$config['db']['path'] = 'sqlite.db3';\n?>/" etc/volkszaehler.conf.php; fi;" 应导致一个配置文件的结尾如下: <?php //.. various other options $config['
sh -c "if [ '$DB' = 'sqlite' ]; then sed -i "s/\?>/\$config['db']['path'] = 'sqlite.db3';\n?>/" etc/volkszaehler.conf.php; fi;"
应导致一个配置文件的结尾如下:
<?php
//.. various other options
$config['db']['path'] = 'sqlite.db3';
?>
sh -c '
if [ "$DB" = "sqlite" ]; then
sed -i "s/\?>/\$config[\'db\'][\'path\'] = \'sqlite.db3\';\n?>/" etc/volkszaehler.conf.php
fi'
或在cygwin上:
sh: / etc/volkszaehler.conf.php; fi;: No such file or directory
要达到目的,正确的引用/转义是什么?您似乎有引用问题。我想试试这样的东西:
<?php
//.. various other options
$config['db']['path'] = 'sqlite.db3';
?>
sh -c '
if [ "$DB" = "sqlite" ]; then
sed -i "s/\?>/\$config[\'db\'][\'path\'] = \'sqlite.db3\';\n?>/" etc/volkszaehler.conf.php
fi'
如果系统支持它,我也会删除
sh-c
和最外层的引号。你在使用什么操作系统?不确定:使用worker:worker-linux-5-2.bb.travis ci.org:travis-linux-13()travis ci似乎出于任何原因需要sh-c。最后的结果是:sh-c“if['$DB'='sqlite'];然后sed-i的/\?>/\$config[''\''DB'\''']['\'''path'\''''''''']\=\'''''sqlite.db3'\'\''\'\n?>/'etc/volkszaehler.conf.php;fi;”