我正在尝试创建一个.sh在内部运行补丁的文件。因此,patch -p0与其在脚本旁边运行补丁文件,不如将补丁嵌入其中。
我尝试了以下
patch -p0 <<EOF
Index: app/code/Magento/CustomerImportExport/Model/Import/Customer.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/code/Magento/CustomerImportExport/Model/Import/Customer.php (date 1487543450000)
+++ app/code/Magento/CustomerImportExport/Model/Import/Customer.php (revision )
@@ -371,6 +371,7 @@
// attribute values
foreach (array_intersect_key($rowData, $this->_attributes) as $attributeCode => $value) {
if ($newCustomer && !strlen($value)) {
+ $entityRow[$attributeCode] = $value;
continue;
}
EOF
Run Code Online (Sandbox Code Playgroud)
但它不起作用。但是,当我patch -p0在原始补丁文件上运行时,它可以正常工作。任何线索可能是错误的?
谢谢,
小智 6
尝试以下建议:Re: [bug-patch] patch 2.6.1 with here document in a shell script
把上面的改成这样,效果会更好:
补丁 -p0 <<'EOF'
如果没有引号,您下面的脚本会在此处的脚本中扩展像 $@ 这样的结构。