I understand that exec
can do I/O redirection on the current shell, but I only sees usage like:
exec 6<&0 # Link file descriptor #6 with stdin.
# Saves stdin.
exec 6>&1 # Link file descriptor #6 with stdout.
# Saves stdout.
From that I understand that <
is for input stream, >
is for output stream. So what does exec 3<&1
do?
PS: I found this from Bats source code
Best Answer
From
bash manpage
:I did some debugs with
strace
:For
3<&1
:For
3>&1
:For
2>&1
:It seems that
3<&1
do exactly the same as3>&1
, duplicating stdout to file descriptor 3.