The difference between redirection with and without exec

64 views Asked by At

Anyone clarify what the definitive difference between:

 3<&0

and

 exec 3<&0

of bash or other akin shell? thanks before

1

There are 1 answers

0
oguz ismail On BEST ANSWER

The difference is that file descriptor 3 remains open after exec 3<&0. See:

$ cat foo
bar
$
$ 3<foo
$ cat <&3
bash: 3: Bad file descriptor
$
$ exec 3<foo
$ cat <&3
bar
$