shopt-option

checkwinsize shell option

Checks terminal dimensions after external commands and updates LINES and COLUMNS when needed. It relies on terminal information, not file or screen pixel sizes. The reference fixture checks option state; a separate PTY resize fixture verifies the dimension change. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): enabled then disabled.

Formal Syntax & Structure

bash syntaxbash
shopt -s checkwinsize; shopt -u checkwinsize

Return Value

exit status

Returns zero on success and nonzero on failure; option queries return zero when enabled.

Working Example

Example Snippetbash
shopt -s checkwinsize || exit 1shopt -q checkwinsize || exit 1shopt -u checkwinsize || exit 1if shopt -q checkwinsize; then exit 1; fiprintf "enabled then disabled\n"
Bash Reference