From owner-freebsd-questions Sun Dec 2 16:15:52 2001 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-11.mail.nl.demon.net [194.159.73.21]) by hub.freebsd.org (Postfix) with ESMTP id 3182E37B41A for ; Sun, 2 Dec 2001 16:15:46 -0800 (PST) Received: from [212.238.194.207] (helo=tanya.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.33 #1) id 16Aglt-000DXO-00 for freebsd-questions@FreeBSD.ORG; Mon, 03 Dec 2001 00:15:45 +0000 Received: by tanya.raggedclown.net (tanya.raggedclown.net, from userid 500) id AADFF1120; Mon, 3 Dec 2001 01:15:43 +0100 (CET) Date: Mon, 3 Dec 2001 01:15:43 +0100 From: Cliff Sarginson To: freebsd-questions@freebsd.org Subject: Re: Changing $IFS in a bash shell Message-ID: <20011203011543.A8286@raggedclown.net> References: <200112022343.fB2Nh6k27466@c1742628-a.vncvr1.wa.home.com> <3C0AC0D9.BFD0604B@pantherdragon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3C0AC0D9.BFD0604B@pantherdragon.org> User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Dec 02, 2001 at 04:01:29PM -0800, Darren Pilgrim wrote: > chk no wrote: > > Changing IFS is usually not the best way to do things. Changing IFS > > can break other scripts, other parts of your script, & is generally > > only used as a last resort. > I disagree. You can save and restore the IFS if you are worried about it. But the IFS is only changed in the script itself (as long as you don't source it, but that is not a likely scenario here). > How else do you recommend I alter the criteria bash uses for its > word-splitting routine? > > Redefining IFS in a script isn't a problem at all. The value will only > last for duration of the script, inside that script only. > > > Instead, try things like: > > > > eval ... |sed "{ More processes, more things to go wrong, more vulnerability to malformed data. > > > I'm doing it with a for-in-do loop to avoid having to use external > programs. This is going to be part of a web-front end for a file > archive, and the fewer external programs the scripts have to call the > better. > Precisely. What you are doing is the correct way to do it IMHO. -- Regards Cliff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message