I'm reading a book about Linux command line where author doesn't seem to follow the conventions in bash manual regarding arrows symbols used in redirection operations. Namely, he always uses left arrow <
in duplicating and closing file descriptors regardless of whether the descriptors are input or output ones.
Here is an example:
exec 3<&0 4<&1 #shouldn't be 4>&1 ?
exec 3<&- 4<&- #shouldn't be 4>&- ?
Bash man page is vague in this point, according to it, the duplicating/closing and moving file descriptors have the following syntaxes:
#Duplicating and closing (in case word expands to -):
They are described to have different behaviour only if we don't explicitly supply the n
. But when we do, does it mean that we can use these forms interchangeably?
OK, now I know that these forms are the same, they both use dup2(1, 4)
system call to duplicate 1 fd.