Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ncoast.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon Allbery) Newsgroups: net.unix-wizards Subject: sh (line parsing) went that-a-way??? Message-ID: <951@ncoast.UUCP> Date: Mon, 13-Jan-86 21:04:07 EST Article-I.D.: ncoast.951 Posted: Mon Jan 13 21:04:07 1986 Date-Received: Wed, 15-Jan-86 08:06:36 EST References: <649@watmath.UUCP> <424@well.UUCP> <14363@rochester.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: net.unix-wizards Organization: Cleveland Public Access UNIX, Cleveland, OH Lines: 49 Expires: Quoted from <14363@rochester.UUCP> ["Re: Redirection quirks: 2>&1 >file -- vs. -- >file 2>&1"], by ken@rochester.UUCP (Ipse dixit)... +--------------- | ->> cat d.c | main() | { | printf("Hello world\n"); | if (open("/etc/phones", 2) < 0) | perror("/etc/phones"); | } | ->> a.out 2>&1 > xxx | /etc/phones: No such file or directory | ->> cat xxx | Hello world | ->> a.out > xxx 2>&1 | ->> cat xxx | /etc/phones: No such file or directory | Hello world | ->> 2>&1 a.out > xxx | ->> cat xxx | /etc/phones: No such file or directory | Hello world | ->> +--------------- As cribbed from debugging a locally-modified calendar(1): (I hope this one piece of code doesn't get me into licensing trouble! :-) % cat test1 eval x=foo y=bar echo baz % sh -x test1 y=bar x=foo <=- ...swapped???... + echo baz baz % Apparently the shell parses at least part of the command string *backwards*. But since "2>&1 >foo" and ">foo 2>&1" work as if it were parsed forward, I don't know where the change in direction occurs. (And since we don't have sources, I can't check...) Times like this make me think TOPS-20 is heaven! (:-) --Brandon -- From the Heart of the Golden Apple... ..decvax!cwruecmp!ncoast!tdi2!brandon (cwruecmp is Case.CSNET, O ye Arpanauts) (..ncoast!tdi2!root for business) 6615 Center St. #A1-105, Mentor, OH 44060 Phone: +01 216 974 9210 CIS 74106,1032 MCI MAIL BALLBERY (part-time)