是否可以在bash函数中插入一个Heredoc?
下面的简单示例将导致错误: ./heredoc_in_function.sh: 10: Syntax error: end of file unexpected (expecting "}")
#!/bin/sh
my_function () {
cat <<HEREDOC
heredoc contents
HEREDOC
}
my_function
环境:
- Ubuntu 11.04(GNU / Linux 2.6.38-8-服务器x86_64)
 - GNU bash版本4.2.8(1)-发行版(x86_64-pc-linux-gnu)
 
                  我觉得Heredoc是Perl的东西。有什么理由相信它可以在BASH中运行吗?
                
                
                  
                    —
                    2011年
                    
                  
                
              
                  @jdw,此处的文档以多种语言(包括bash)提供。
                
                
                  
                    —
                    Zoredache 
                    
                  
                
              
                  我现在知道了。凉。
                
                
                  
                    —
                    jdw 2011年