From owner-freebsd-standards@FreeBSD.ORG Wed Mar 18 12:13:50 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 A046A1065C41 for ; Wed, 18 Mar 2009 12:13:50 +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 1DDFF8FC18 for ; Wed, 18 Mar 2009 12:13:49 +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 n2ICDPPX042351; Wed, 18 Mar 2009 13:13:48 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id n2ICDPpT042350; Wed, 18 Mar 2009 13:13:25 +0100 (CET) (envelope-from olli) Date: Wed, 18 Mar 2009 13:13:25 +0100 (CET) Message-Id: <200903181213.n2ICDPpT042350@lurza.secnetix.de> From: Oliver Fromme To: freebsd-standards@FreeBSD.ORG 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]); Wed, 18 Mar 2009 13:13:49 +0100 (CET) Cc: Subject: 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: Wed, 18 Mar 2009 12:13:53 -0000 Hello, According to the sh(1) manpage and the SUSv3 wording, the order of characters in the IFS variable should not matter for field splitting. However, I get strange results with our /bin/sh ... I'm trying to parse config files that look like this: ip = 10.1.2.3 host = some.name desc = some description here That is, the format of lines is this: * "=" * Of course that should be simple: Just add "=" to $IFS and read the lines in a loop, like the following (the echo command is for debugging; the real shell code uses the setvar command instead): IFS="=$IFS" while read key val; do echo "'$key' -- '$val'" done < config However, the "=" characters and some spaces are included in $val, which is wrong behaviour, I think. I get this output: 'ip' -- ' = 10.1.2.3' 'host' -- '= some.name' 'desc' -- '= some description here' If I change the IFS line like this (diff -u format): - IFS="=$IFS" + IFS="$IFS=" then I get the correct and expected output: 'ip' -- '10.1.2.3' 'host' -- 'some.name' 'desc' -- 'some description here' Note that the characters in IFS are exactly the same, only the order is different. On Solaris, the same shell script produces correct output in both cases, independent from the order of characters in IFS. I've also tested zsh and bash: They also produce correct output in both cases. So this really seems to be a bug in FreeBSD's /bin/sh. I'm about to file a PR, but I suppose it's better to ask the standards mailinglist first, so here I am. 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