From owner-freebsd-standards@FreeBSD.ORG Thu Mar 19 14:13:04 2009 Return-Path: Delivered-To: freebsd-standards@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5907810656D0 for ; Thu, 19 Mar 2009 14:13:04 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id CDAF48FC20 for ; Thu, 19 Mar 2009 14:13:03 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id n2JECdDM011121; Thu, 19 Mar 2009 15:13:02 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id n2JECdbl011120; Thu, 19 Mar 2009 15:12:39 +0100 (CET) (envelope-from olli) Date: Thu, 19 Mar 2009 15:12:39 +0100 (CET) Message-Id: <200903191412.n2JECdbl011120@lurza.secnetix.de> From: Oliver Fromme To: freebsd-standards@FreeBSD.ORG In-Reply-To: <200903181213.n2ICDPpT042350@lurza.secnetix.de> X-Newsgroups: list.freebsd-standards User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Thu, 19 Mar 2009 15:13:02 +0100 (CET) Cc: Subject: Re: Suspecting bug in /bin/sh's IFS X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2009 14:13:04 -0000 Further debugging reveals that this is not a generic problem with field splitting, but it affects the read command only. I tried to use "set" instead of "read": ORIG_IFS="$IFS" while read line; do IFS="$IFS=" set -- $line IFS="$ORIG_IFS" key="$1" shift val="$*" echo "'$key' -- '$val'" done < config Now i get correct output for both " \t\n=" and "= \t\n" as the IFS value. So the bug is in the "read" builtin. The following patch fixes the problem: --- bin/sh/miscbltin.c.orig 2006-02-04 15:37:50.000000000 +0100 +++ bin/sh/miscbltin.c 2009-03-19 15:01:43.000000000 +0100 @@ -188,7 +188,7 @@ } if (c == '\n') break; - if (startword && *ifs == ' ' && strchr(ifs, c)) { + if (startword && strchr(ifs, c)) { continue; } startword = 0; The bug seems to exist for at least 15 years; the bogus comparison was already present in the initial import in the FreeBSD CVS repository in 1994. Any opinions on this? Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "Whatever happened to the days when hacking started at the cerebral cortex, and not at the keyboard?" -- Sid on userfriendly.org by Illiad, 2007-06-20