在sh文件中嵌入补丁文件

Embed patch file in sh file

我正在尝试创建一个 .sh 文件,它在内部 运行 是一个补丁。因此,我希望将补丁嵌入其中,而不是 运行ning 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

但它不起作用。但是,当我 运行 patch -p0 在原始补丁文件上时,它可以正常工作。任何线索可能是错的?

谢谢,

尝试以下建议:Re: [bug-patch] patch 2.6.1 with here document in a shell script

Change the above to this, and it will work better:

patch -p0 <<'EOF'

Without the quotes, your script below expands constructs like $@ in the here script.