Small script to verify hash of a downloaded file
Notes:


I'd use getopts for arg parsing -- lots of examples on stackoverflow about how to use it.
always quote your variables
you should validate the algorithm:

sum_exe="${algo}sum"
if ! type -P "$sum_exe" &gt;/dev/null; then
    error_exit "'$algo' is an unknown checksum algorithm"
fi

have the checksum program read from stdin, then you don't have to do your incorrect unsafe word parsing since the program will not print a filename

hash_calc=$( "$sum_exe" &lt; "$downloaded_file" )




As the above doesn't work, let's use read from a process substitution

read -r hash_calc _ &lt; &lt;("$sum_exe" &lt; "$downloaded_file")