英文:
The difference between redirection with and without exec
问题
"3<&0" 与 "exec 3<&0" 在Bash或其他类似的shell中的确切区别是什么?谢谢。
英文:
Anyone clarify what the definitive difference between:
3<&0
and
exec 3<&0
of bash or other akin shell?
thanks before
答案1
得分: 5
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
$
英文:
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
$
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论