这是我的 run.sh 文件:
#!/bin/sh
before=$(cat <<EOF
require SYSPATH.'core/Bootstrap'.EXT;
EOF
)
after=$(cat <<EOF
if(strpos($_SERVER['SCRIPT_NAME'], 'phpunit'){
sometext # <= without it works fine!
EOF
)
sed -i.bak "s|$before|$after|g" "$2"
错误
sed:-e 表达式 #1,字符 79:未终止的“s”命令
工作正常,但我想替换多行文本!
#!/bin/sh
before=$(cat <<EOF
require SYSPATH.'core/Bootstrap'.EXT;
EOF
)
after=$(cat <<EOF
if(strpos($_SERVER['SCRIPT_NAME'], 'phpunit'){
EOF
)
sed -i.bak "s|$before|$after|g" "$2"
答案1
这修复了它:
if(strpos($_SERVER['SCRIPT_NAME'], 'phpunit'){ \n \ # <= BACKSLASH needed!
sometext