From owner-freebsd-hackers Mon Mar 6 1:46:48 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from dt051n0b.san.rr.com (dt051n0b.san.rr.com [204.210.32.11]) by hub.freebsd.org (Postfix) with ESMTP id 3345937BCED for ; Mon, 6 Mar 2000 01:46:44 -0800 (PST) (envelope-from Doug@gorean.org) Received: from gorean.org (doug@master [10.0.0.2]) by dt051n0b.san.rr.com (8.9.3/8.9.3) with ESMTP id BAA11287; Mon, 6 Mar 2000 01:44:35 -0800 (PST) (envelope-from Doug@gorean.org) Message-ID: <38C37E03.A49AD802@gorean.org> Date: Mon, 06 Mar 2000 01:44:35 -0800 From: Doug Barton Organization: Triborough Bridge & Tunnel Authority X-Mailer: Mozilla 4.72 [en] (X11; U; FreeBSD 4.0-CURRENT-0302 i386) X-Accept-Language: en MIME-Version: 1.0 To: Warner Losh Cc: Sheldon Hearn , Max Khon , hackers@FreeBSD.ORG Subject: Re: empty lists in for References: <34889.952334114@axl.ops.uunet.co.za> <200003060932.CAA57921@harmony.village.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Warner Losh wrote: > > In message <34889.952334114@axl.ops.uunet.co.za> Sheldon Hearn writes: > : On Mon, 06 Mar 2000 00:59:39 PST, Doug Barton wrote: > : > : > for name [ in word ] > : > do > : > compound-list > : > done > : > > : > the "in word" is optional. Therefore: > : > : Hmmm, you're right. > : > : I must admit, though, that if the text is confusing enough to confuse > : me, it's not entirely clear (even if I'm not the hardest person in the > : world to confuse)! > > Are you sure that "word" here means one or more tokens, or zero or > more tokens. If it means zero or more tokens, then 'for i in ; do ' > is perfectly legal. You're not quoting what word means. > > The reason that I ask this is that I can't see why > for i in ; do > would be any different than > for i in $foo; do > when foo is empty. They are the same thing from at last my world view > of the shell. The context of the text (previously quoted) clearly expects that "word" be expanded. An expansion which evaluates to an empty set is different from a lack of "word" to be expanded at all. That's why "in word" is optional, but "word" isn't. IIRC, $name can be set outside of the expression, which would allow it to be acted on within the list. At the same time, I'd also like to see if POSIX has a clear definition of "word." Doug -- "Welcome to the desert of the real." - Laurence Fishburne as Morpheus, "The Matrix" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message