This command is part of the TclX package.
Duplicate an open file. A new file id is opened that addresses the same file as fileId.
If targetFileId is specified, the the file is dup-ped to this specified file id. Normally this is stdin, stdout, or stderr. The dup command will handle flushing output and closing this file. The new file will be buffered, if its needs to be unbuffered, use the fcntl command to set it unbuffered.
If fileId is a number rather than a Tcl channel name, then the dup command will bind that file to a Tcl channel. This is useful for accessing files that are passed from the parent process. The targetFileId argument is not valid with this operation.
On Windows 95/NT, only stdin, stdout, or stderr or a non-socket file handle number maybe specified for targetFileId. The dup command does not work on sockets on Windows 95/NT.