title: in bash, heredoc inside function returns syntax error
body: <p>I have the following function:</p>
  
  <pre><code>#!/bin/bash
  
  get_instance{
  dbname=$(sqlplus -s / as sysdba&lt;&lt;EOF
  set pages 0
  set feedback off
  select name from v\$database;
  exit;
  EOF)
  
  echo $dbname
  
  }
  
  get_instance
  </code></pre>
  
  <p>It seems to work. In the middle of the error message, I get my <code>dbname</code>, but still returns a syntax error.</p>
  
  <pre><code> oracle@testdb01:db01:/home/oracle/
   &gt; ./test.sh
   ./test.sh: line 3: get_instance{: command not found
   DB01
   ./test.sh: line 11: syntax error near unexpected token `}'
   ./test.sh: line 11: `}'
  </code></pre>
  
  <p>If I remove the function call completely, I get the result with no errors:</p>
  
  <pre><code>dbname=$(sqlplus -s / as sysdba&lt;&lt;EOF
  set pages 0
  set feedback off
  select name from v\$database;
  exit;
  EOF)
  echo $dbname
  
  oracle@testdb01:db01:/home/oracle
  &gt; ./test.sh
  DB01
  </code></pre>
  
  <p>What do I need to do to get this to work in a function?</p>
  
  <h2>EDIT:</h2>
  
  <p>Following suggestion to place bracket after EOF tag and add function keyword:</p>
  
  <pre><code> &gt; vi test.sh
   "test.sh" 12 lines, 160 characters
  
  #!/bin/bash
  # updated file
  function get_instance{
  dbname=$(sqlplus -s / as sysdba&lt;&lt;EOF
  set pages 0
  set feedback off
  select name from v\$database;
  exit;
  EOF
  )
  echo $dbname
  }
  
  get_instance
  
  oracle@testdb01:db01:/home/oracle
  &gt; ./test.sh
  ./test.sh: line 10: syntax error near unexpected token `dbname=$(sqlplus -s / as sysdba&lt;&lt;EOF
  set pages 0
  set feedback off
  select name from v\$database;
  exit;
  EOF
  )'
  </code></pre>
  
  <p>./test.sh: line 10: `)'</p>