Just a side note: if you obtain a cleartext password into PASSWORD variable and then use echo $PASSWORD command, then the cleartext password will be visible in the process list for everyone. Thus should be avoided.
The using --askpass option, as @MadeInGermany mentioned is a much more secure way to do the same.
Good point.
But here the echo command is a shell-builtin, and in most if not all shells the builtins don't fork/exec to new processes.
Yes, the external /usr/bin/echo command would be unsafe.
Furthermore, <<< “$PASSWORD” sudo --stdin ... would be unsafe: the "here string" is saved in /tmp/