i am making a shell that will redirect < and > linux says redirection is handled left to right
but if this is true then the following would not work
1)tee newOutputFile1 < existingInputFile > newOutputFile2
according to the man page the input is first overwritten, then the output is overwritten if that is true, then by the time that newOutputFile2 gets set to stdout tee would have already started, and then newOutputFile2 would be wrong.
this is what i understand that it does
2)tee newOutputFile1 < existingInputFile > newOutputFile2
will first set newOutputfile2 as the stdout, and then set stdin as existingInputFile contents.
but if that is true then
3)tee newOutputFile1 > newOutputFile2 < existingInputFile
would execute the opposite and break things.
so when there is both < and > does it just assume first set stdout then set stdin?
newOutputFile2
gets set tostdout
,tee
would have already started". Nope, there's your mistake. A fork happens to prevent messing up the streams of the main shell, then all the redirections take place in left-to-right order, (freopen
), and the last step is to useexec
to replace the fork child with thetee
executable.