title: How to get psql result in bash?
body: <p>I'm trying to get the psql result in bash</p>
  
  <pre><code>echo 'SELECT * FROM fictive_table LIMIT 1;' &gt;&gt; /tmp/x.sql
  psql --single-transaction -d dbname -f /tmp/x.sql
  echo $?
  </code></pre>
  
  <p>This will fail but the result I get in bash is 0. Is there a problem with the logic/code?</p>
  
  <p>From the manual</p>
  
  <blockquote>
    <p>psql  returns  0  to  the shell if it finished normally, 1 if a fatal
    error of its own (out of memory, file not found) occurs</p>
  </blockquote>
  
  <p>Update:
  @Andrea Spadaccini is right. This is not fatal. How can I catch it ?</p>