The following script:
#!/bin/sh set -u; printf "$notset\\n"; printf "I am not displayed\\n";
gives the expected error: