From owner-freebsd-hackers Fri Sep 21 21:25:47 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp.bmi.net (smtp.bmi.net [204.57.191.31]) by hub.freebsd.org (Postfix) with ESMTP id E408337B403 for ; Fri, 21 Sep 2001 21:25:43 -0700 (PDT) Received: from johncoop.MSHOME (drumheller-router.bmi.net [206.63.201.3] (may be forged)) by smtp.bmi.net (Pro-8.9.3/Pro-8.9.3) with ESMTP id EAA15191; Sat, 22 Sep 2001 04:32:46 -0700 Date: Fri, 21 Sep 2001 21:25:30 -0700 From: John Merryweather Cooper To: Mario Sergio Fujikawa Ferreira Cc: freebsd-hackers@freebsd.org Subject: Re: bug in shell `` expansion code? Message-ID: <20010921212530.G24650@johncoop.MSHOME> References: <20010922011302.A44620@exxodus.fedaykin.here> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit In-Reply-To: <20010922011302.A44620@exxodus.fedaykin.here>; from lioux@uol.com.br on Fri, Sep 21, 2001 at 21:13:02 -0700 X-Mailer: Balsa 1.2.0 Lines: 51 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2001.09.21 21:13 Mario Sergio Fujikawa Ferreira wrote: > Hi, > > While working on a make .mk code, I and Chris Wasser (TDF > on IRC) came across an interesting behavior: > > sh -c 'TDF="echo a && echo b";for i in `${TDF}`; do echo "i:$i"; done' > > This should return: > > i:a > i:b > > instead, it returns: > > i:a > i:&& > i:echo > i:b > > If this is not a bug, how do we get it working? > > Regards, > > -- > Mario S F Ferreira - UnB - Brazil - "I guess this is a signature." > lioux at ( freebsd dot org | linf dot unb dot br ) > flames to beloved devnull@someotherworldbeloworabove.org > feature, n: a documented bug | bug, n: an undocumented feature > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > This works: $ sh -c 'TDF="echo a && echo b";for i in `eval ${TDF}`; do echo "i:$i"; done' I believe eval is necessary in this context, otherwise the && is not "evaluated." I checked, and the same behavior holds if sh is changed to bash. -- jmc MacroHard -- the perfection of form over substance, marketing over performance, and greed over design . . . To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message