title: bc: prevent "divide by zero" runtime error on multiple operations
body: <p>I'm using bc to do a series of calculation.</p>
  
  <p>I'm calling it though a bash script that first of all puts all the expressions to be calculated in a single variable, the passes them to bc to calculate the results.</p>
  
  <p>The script is something like that:</p>
  
  <pre><code>#!/bin/bash
  ....
  
  list=""
  
  for frml in `cat $frmlList`
  do
      value=`echo $frml`
      list="$list;$value"
  done
  
  echo "scale=3;$list"| bc
  </code></pre>
  
  <p>the frmlList variable contains a list of expressions that are the output of another program, for simplicity i don't mention every operation, but on its contents are done some sed operations before to assign it to the "value" variable.</p>
  
  <p>In the end, the "list" variable contains a list of expressions separated by semicolon that bc understands.</p>
  
  <p>Now what happens is that in my formula list, sometimes happens that there is a division by 0.</p>
  
  <p>When it happens bc stops its computation giving a "Runtime Error: divide by zero".</p>
  
  <p>I would bc to not end its work on that error, but to skip it and continue with the next formula evaluation.</p>
  
  <p>Is possible to achieve something like that?</p>
  
  <p>The same thing happens in a simpler situation:</p>
  
  <pre><code>echo "scale=2;1+1;1/0;2+2;" | bc
  </code></pre>
  
  <p>the output is</p>
  
  <pre><code>2
  Runtime error (func=(main), adr=17): Divide by zero
  </code></pre>
  
  <p>I would like to have something like</p>
  
  <pre><code>2
  Runtime error (func=(main), adr=17): Divide by zero
  4
  </code></pre>
  
  <p>Thank you in advance :)</p>