Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!linus!decvax!decwrl!pyramid!ut-sally!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.unix-wizards Subject: Re: Redirection quirks: 2>&1 >file -- vs. -- >file 2>&1 Message-ID: <176@hadron.UUCP> Date: Mon, 6-Jan-86 09:47:41 EST Article-I.D.: hadron.176 Posted: Mon Jan 6 09:47:41 1986 Date-Received: Wed, 8-Jan-86 20:13:12 EST References: <649@watmath.UUCP> <424@well.UUCP> <350@bdaemon.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 21 Summary: Some interpreted left-right, other right-left. In article <350@bdaemon.UUCP> carl@bdaemon.UUCP (carl) writes: >> In article <649@watmath.UUCP> idallen@watmath.UUCP writes: >> > $ command 2>&1 >file >> > $ command >file 2>&1 >> >These are not equivalent using our 4.2bsd Bourne shell. (The 2>&1 in the >> >first line redirects unit 2 to the tty, not to the file.) >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. To convince yourself, try > foobar=${foo}${bar} foo="hello" bar=" world" >versus > foo="hello" bar=" world" foobar=${foo}${bar} Since the '>'s are obviously interpreted left to right, this can't be universally true. Apparently, some things are interpreted left-right and others right-left. Actually, I would have expected the assignments to be interpreted in parallel, and so in both they would have assigned foobar = "". -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}