shopt-option
Bash varredir_close
Automatically closes descriptors allocated by command-scoped {varname} redirections when the command completes. Explicit exec redirections are a separate lifetime case.
Formal Syntax & Structure
bash syntaxbash
shopt -s varredir_closeReturn Value
exit status
Automatically closes descriptors allocated by command-scoped {varname} redirections when the command completes. Explicit exec redirections are a separate lifetime case.
Working Example
Example Snippetbash
shopt -s varredir_closeprintf 'one\n' {fd}> log.txt >&"$fd"if (printf 'two\n' >&"$fd") 2> error.txt; then printf 'unexpected\n'; else printf 'closed\n'; ficat log.txt