Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site basser.oz Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!amdcad!lll-crg!seismo!munnari!basser!john From: john@basser.oz (John Mackin) Newsgroups: net.unix-wizards Subject: Re: Redirection quirks: 2>&1 >file -- vs. -- >file 2>&1 Message-ID: <500@basser.oz> Date: Tue, 7-Jan-86 17:28:14 EST Article-I.D.: basser.500 Posted: Tue Jan 7 17:28:14 1986 Date-Received: Wed, 8-Jan-86 23:53:01 EST References: <649@watmath.UUCP> <424@well.UUCP> <350@bdaemon.UUCP> Reply-To: john@basser.UUCP (John Mackin) Organization: Dept of Comp Sci, Uni of Sydney, Australia Lines: 35 In article <350@bdaemon.UUCP> carl@bdaemon.UUCP (Carl Brandauer) writes: > The real explanation for all of this is that once a Bourne shell command > line has been read (up to \n or ; or & etc.) it is evaluated from right to > left. Incorrect. In the case you gave, evaluation may indeed proceed from right to left; the order of evaulation is not documented. But if you examine the original posting, you will see the statement > $ command 2>&1 >file > $ command >file 2>&1 > The 2>&1 in the first line redirects unit 2 to the tty, not to the file. This statement is *correct*. The redirections are evaluated from LEFT to RIGHT, not from right to left. In the (Eighth Edition) sh(1) manual entry on our system, this behavior is documented: The order in which redirections are specified is significant. The shell evaluates redirections left-to- right. For example: ... 1>xxx 2>&1 first associates file descriptor 1 with file xxx. It associates file descriptor 2 with the file associated with file descriptor 1 (i.e. xxx). If the order of redirections were reversed, file descriptor 2 would be associated with the terminal (assuming file descriptor 1 had been) and file descriptor 1 would be associated with file xxx. John Mackin, Basser Department of Computer Science, University of Sydney, Sydney, Australia seismo!munnari!basser.oz!john john%basser.oz@SEISMO.CSS.GOV