shopt -s checkwinsize only works in interactive shells. However, this is not mentioned in the manual.
Tested in Bash 4.2.37. #!/bin/bash trap 'echo "COLUMNS is now <$COLUMNS>"' WINCH test -z "$COLUMNS" && COLUMNS=$(tput cols) shopt -s checkwinsize while sleep 1; do :; done Run in a terminal, resize the terminal repeatedly. COLUMNS is never updated after its initial setting. Set the same trap in an interactive shell, and resize the terminal repeatedly. COLUMNS will be updated each time.