title: Correctly count number of lines a bash variable
body: <p>I need to count the number of lines of a given variable. For example I need to find how many lines <code>VAR</code> has, where <code>VAR=$(git log -n 10 --format="%s")</code>.</p>
  
  <p>I tried with <code>echo "$VAR" | wc -l)</code>, which indeed works, but if <code>VAR</code> is empty, is prints <code>1</code>, which is wrong. Is there a workaround for this? Something better than using an <code>if</code> clause to check whether the variable is empty...(maybe add a line and subtract 1 from the returned value?).</p>