On Sun, Mar 03, 2024 at 10:29:17PM +0000, Venkat Raman via Bug reports for the 
GNU Bourne Again SHell wrote:
> Repeat-By:
>         exec 2>&test1 commands freezes the terminal and unable to close the 
> fd.
> 
> Fix:
>         [Is there a sane  way to close the fd?]

You're using the wrong syntax.

To open a file (for writing + truncation):  exec 2>file

To open a file (for appending):  exec 2>>file

To close a file descriptor:  exec 2>&-


The command that you ran (exec 2>&test1) redirects stderr which is
normally opened to the terminal.  In order to get it back, you would
need to do something like  exec 2>&1   assuming stdout has not been
altered yet.

The shell prompt is normally written to stderr, so you won't see the
prompt until stderr is restored.

  • Unable to clos... Venkat Raman via Bug reports for the GNU Bourne Again SHell
    • Re: Unabl... Greg Wooledge

Reply via email to