Parameters: url sha256 [filename].
If unset, it gets a filename from the URL.
If verification fails, it saves to $filename.invalid
get_remote_file() {
test -z "$1" -o -z "$2" && (echo "Usage: $0 remote_url content_sha256sum [output_filename]"; return $?);
local file=$(test -n "$3" && echo $3 || basename $1|tr -dc '[:alnum:]\.\-\_\:\/');
wget -O $file $1 && (sha256sum -c <(printf "%s\t%s" $2 $file) || mv $file $file.invalid);
return $?
}