From owner-freebsd-stable@FreeBSD.ORG Mon Oct 4 16:29:37 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DC7D106566B for ; Mon, 4 Oct 2010 16:29:37 +0000 (UTC) (envelope-from peter@simons-rock.edu) Received: from hedwig.simons-rock.edu (hedwig.simons-rock.edu [208.81.88.14]) by mx1.freebsd.org (Postfix) with ESMTP id EA5058FC13 for ; Mon, 4 Oct 2010 16:29:36 +0000 (UTC) Received: from cesium.hyperfine.info (c2.8d.5646.static.theplanet.com [70.86.141.194]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by hedwig.simons-rock.edu (Postfix) with ESMTP id 47F482BB34A; Mon, 4 Oct 2010 11:57:04 -0400 (EDT) Date: Mon, 4 Oct 2010 11:57:02 -0400 From: "Peter C. Lai" To: Miroslav Lachman <000.fbsd@quip.cz> Message-ID: <20101004155702.GH70616@cesium.hyperfine.info> References: <4CA78EE3.9020005@quip.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CA78EE3.9020005@quip.cz> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-stable Subject: Re: is there a bug in AWK on 6.x and 7.x (fixed in 8.x)? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2010 16:29:37 -0000 Is this becuase the behavior of "FS=" was changed to match the behavior of awk -F On 2010-10-02 09:58:27PM +0200, Miroslav Lachman wrote: > I think there is a bug in AWK in base of FreeBSD 6.x and 7.x (tested on > 6.4 i386 and 7.3 i386) > > I have this simple test case, where I want 2 columns from GeoIP CSV file: > > awk 'FS="," { print $1"-"$2 }' GeoIPCountryWhois.csv > > It should produce output like this: > > # awk 'FS="," { print $1"-"$2 }' GeoIPCountryWhois.csv | head -n 5 > "1.0.0.0"-"1.7.255.255" > "1.9.0.0"-"1.9.255.255" > "1.10.10.0"-"1.10.10.255" > "1.11.0.0"-"1.11.255.255" > "1.12.0.0"-"1.15.255.255" > > (above is taken from FreeBSD 8.1 i386) > > On FreeBSD 6.4 and 7.3 it results in broken first line: > > awk 'FS="," { print $1"-"$2 }' GeoIPCountryWhois.csv | head -n 5 > "1.0.0.0","1.7.255.255","16777216","17301503","AU","Australia"- > "1.9.0.0"-"1.9.255.255" > "1.10.10.0"-"1.10.10.255" > "1.11.0.0"-"1.11.255.255" > "1.12.0.0"-"1.15.255.255" > > There are no errors in CSV file, it doesn't metter if I delete the > affected first line from the file. > > It is reproducible with handmade file: > > # cat test.csv > "1.9.0.0","1.9.255.255","17367040","17432575","MY","Malaysia" > "1.10.10.0","1.10.10.255","17435136","17435391","AU","Australia" > "1.11.0.0","1.11.255.255","17498112","17563647","KR","Korea, Republic of" > "1.12.0.0","1.15.255.255","17563648","17825791","CN","China" > "1.16.0.0","1.19.255.255","17825792","18087935","KR","Korea, Republic of" > "1.21.0.0","1.21.255.255","18153472","18219007","JP","Japan" > > > # awk 'FS="," { print $1"-"$2 }' test.csv > "1.9.0.0","1.9.255.255","17367040","17432575","MY","Malaysia"- > "1.10.10.0"-"1.10.10.255" > "1.11.0.0"-"1.11.255.255" > "1.12.0.0"-"1.15.255.255" > "1.16.0.0"-"1.19.255.255" > "1.21.0.0"-"1.21.255.255" > > > As it works in 8.1, can it be fixed in 7-STABLE? > (I don't know if it was purposely fixed or if it is coincidence of newer > version of AWK in 8.x) > > Should I file PR for it? > > Miroslav Lachman > _______________________________________________ > freebsd-stable@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-stable > To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org" -- =========================================================== Peter C. Lai | Bard College at Simon's Rock Systems Administrator | 84 Alford Rd. Information Technology Svcs. | Gt. Barrington, MA 01230 USA peter AT simons-rock.edu | (413) 528-7428 ===========================================================