I'd like to know why bash doesn't display an error message when we refer to a closed stderr. When it comes to other file descriptors, they have to be opened if we want to, for example, duplicate them. Stderr seems to be kinda special in this case:
$ cat file_1 echo Test1 1>&5 $ cat file_2 echo Test2 1>&2 $ ./file_1 5>&- ./file_1: line 1: 5: Bad file descriptor $ ./file_1 5>&1 Test1 $ ./file_2 2>&- $ #NO ERROR and no output! $ ./file_2 Test2
Why does the shell allow it?