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
Shell 使用sed为travis构建配置文件_Shell_Sed_Travis Ci - Fatal编程技术网

Shell 使用sed为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['

我试图通过在末尾添加一个条目来更改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['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;”