title: bash get list length when list name is not fixed
body: <p>Suppose I have two lists:</p>
  
  <pre><code>lista="a b c d"
  listb="e f"
  </code></pre>
  
  <p>I would like to write a function that returns the number of items on a given list:</p>
  
  <pre><code>&gt;&gt;foo $lista
  4
  &gt;&gt;foo $listb
  2
  </code></pre>
  
  <p>I've tried using <code>${#&lt;varname&gt;[@]}</code> syntax, also <code>${#!&lt;varname&gt;[@]}</code>, unsuccessfully.</p>
  
  <p>Thanks</p>