Treat unset variables as an error when performing parameter expansion. If expansion is attempted on an unset variable, the shell prints an error message, and, if not interactive, exits with a non-zero status.Example:
vs$ cat hello.sh
#!/bin/sh
NAME=$1
echo Hello $NAME
$ sh hello.sh
Hello
$ cat hellou.sh
#!/bin/sh
set -u
NAME=$1
echo Hello $NAME
$ sh hellou.sh
hellou.sh: line 5: $1: unbound variable
No comments:
Post a Comment