title: Returning a string comparison result - bash
body: <p>I'm writing a small function which compare md512sums of two files.
  I can't say that I'm good in bash, but I need to return a simple result
  commented part is long code. It asks for a reduction.</p>
  
  <p>By the way, if someone have any ideas to improve my code, I'll be grateful.</p>
  
  <pre><code>function TestStage()
  {
      local URL="distfiles.gentoo.org/releases/${1:7:5}/current-stage3/${1}"
      wget -q ${URL}.DIGESTS
      local SUM_WEB=`cat ${1}.DIGESTS | sed '2q;d'`
      local SUM_LOC=`openssl dgst -r -sha512 ${1}`
      ####### time to return
      return [[ "${SUM_WEB:0:128}" == "${SUM_LOC:0:128}" ]]
  
      #if [ "${SUM_WEB:0:128}" == "${SUM_LOC:0:128}" ]
      #then
      #    rm ${1}.DIGESTS
      #    return 0
      #else
      #    rm ${1}.DIGESTS
      #    return 1
      #fi
  }
  </code></pre>
  
  <p>As you may have guessed <code>$1</code> is <code>stage3-&lt;arch&gt;-&lt;release&gt;.tar.bz2</code>.</p>