From owner-freebsd-hackers Sun May 10 03:24:44 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA09777 for freebsd-hackers-outgoing; Sun, 10 May 1998 03:24:44 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from awfulhak.org (awfulhak.demon.co.uk [158.152.17.1]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA09770 for ; Sun, 10 May 1998 03:24:37 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from gate.lan.awfulhak.org (localhost [127.0.0.1]) by awfulhak.org (8.8.8/8.8.8) with ESMTP id KAA20765; Sun, 10 May 1998 10:36:37 +0100 (BST) (envelope-from brian@gate.lan.awfulhak.org) Message-Id: <199805100936.KAA20765@awfulhak.org> X-Mailer: exmh version 2.0.1 12/23/97 To: "John W. DeBoskey" cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Unexpected behaviour from pdksh. Comments? In-reply-to: Your message of "Sat, 09 May 1998 21:52:21 EDT." <199805100152.AA24180@mozart> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 10 May 1998 10:36:37 +0100 From: Brian Somers Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG The *only* shell that executes the last bit of a pipe inline is the original ksh. Pdksh, zsh, sh, ash, bash and probably just about all other shells create a subshell. This is a pain - something | read this that theother must be changed to read this that theother < Hi, > > The following is on 3.0-CURRENT using pdksh. > > Given the following sample Korn Shell script: > > export FOO=foo > echo $FOO > > echo bar | while read var; do > export FOO=$var > echo $FOO > done > > echo $FOO > > The output is: > foo > bar > foo > > where I was expecting: > foo > bar > bar > > > > > If I put the value 'bar' in a file and change the while > loop to: > > echo bar > varfile > while read var; do > export FOO=$var > echo $FOO > done < varfile > > I get the expected reult with the above. > > It seems that the pipe '|' is causing the 'while read var' to > execute in a subshell. Does anyone know of a way to make this > work the way I am expecting it to? fyi: this seems to work ok > under hpux 9.05 & 10.20 and SunOS 5.6... > > Thanks, > John > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message -- Brian , , Don't _EVER_ lose your sense of humour.... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message