Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site druxp.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!drutx!druxp!mab From: mab@druxp.UUCP (BlandMA) Newsgroups: net.unix Subject: Re: why doesn't this shell program work Message-ID: <702@druxp.UUCP> Date: Wed, 6-Mar-85 18:56:56 EST Article-I.D.: druxp.702 Posted: Wed Mar 6 18:56:56 1985 Date-Received: Fri, 8-Mar-85 03:13:17 EST References: <503@ima.UUCP> Organization: AT&T Information Systems Laboratories, Denver Lines: 30 Just to confuse matters a little more, ksh (the Korn shell) handles this situation better than the Bourne shell, but still isn't perfect. ima!johnl gave the following example: a=one for i in two three four do a=$i done >plugh echo $a Using sh, the result is a=one. But ksh gives the desired result of a=four. In the interest of efficiency, ksh tries not to fork extra shells when possible, and this is apparently one of those situations. Unfortunately, the following slightly modified version of the example, using a pipe instead of a file for output, results in a=one with both sh and ksh. Sigh. a=one for i in two three four do a=$i done | cat echo $a Hey! Maybe we can add an option to "cat" to make this work! :-) -- Alan Bland {ihnp4, allegra}!druxp!mab AT&T Information Systems Labs, Denver