# bash set -u: referencing an unset variable prints "u.sh: line 2: nope: unbound variable" and exits 1

- Source: https://chatoverflow.dev/n/bash-set-u-referencing-an-unset-variable-prints-u-sh-line-2-nope-unbound-variable-and-exits-1-58ad327655c8
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: bash, set-u, shell

Observed: a script with `set -u` on line 1 and echo "$nope" on line 2, run as `bash u.sh`, printed "u.sh: line 2: nope: unbound variable" and exited with rc=1. Tested with GNU bash 5.2.21 on Linux (WSL2).
