Dup allows shells
to implement commands like this: ls existing-file non-existing-file > tmp1
2>&1. The 2>&1 tells the shell to give the command a file descriptor 2 that
is a duplicate of descriptor 1.
Both the name of the existing file and the error message for the
non-existing file will show up in the file tmp1. The xv6 shell doesn’t support
I/O redirection for the error file descriptor, but now you know how to implement it.