From owner-freebsd-bugs@FreeBSD.ORG Sat Jan 30 10:30:03 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB76D1065676 for ; Sat, 30 Jan 2010 10:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B97ED8FC1A for ; Sat, 30 Jan 2010 10:30:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o0UAU2Vb033838 for ; Sat, 30 Jan 2010 10:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o0UAU2pl033836; Sat, 30 Jan 2010 10:30:02 GMT (envelope-from gnats) Resent-Date: Sat, 30 Jan 2010 10:30:02 GMT Resent-Message-Id: <201001301030.o0UAU2pl033836@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Mikolaj Golub Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 774E11065670 for ; Sat, 30 Jan 2010 10:21:45 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 4DF8D8FC08 for ; Sat, 30 Jan 2010 10:21:45 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0UALjh6072172 for ; Sat, 30 Jan 2010 10:21:45 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o0UALjCL072171; Sat, 30 Jan 2010 10:21:45 GMT (envelope-from nobody) Message-Id: <201001301021.o0UALjCL072171@www.freebsd.org> Date: Sat, 30 Jan 2010 10:21:45 GMT From: Mikolaj Golub To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/143367: [patch] awk(1) treats -Ft as -F X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2010 10:30:03 -0000 >Number: 143367 >Category: bin >Synopsis: [patch] awk(1) treats -Ft as -F >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jan 30 10:30:02 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Mikolaj Golub >Release: >Organization: >Environment: FreeBSD zhuzha.ua1 8.0-STABLE FreeBSD 8.0-STABLE #6: Sun Jan 24 21:36:17 EET 2010 root@zhuzha.ua1:/usr/obj/usr/src/sys/GENERIC i386 >Description: This problem with awk(1) regexp working incorrectly was reported to NetBSD by Aleksey Cheusov and it was fixed there. http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=39133 FreeBSD version still has this bug: zhuzha:~% echo supertable | awk -Ft '{print $1, $2}' supertable zhuzha:~% echo -e "super\ttable" | awk -Ft '{print $1, $2}' super table >How-To-Repeat: echo supertable | awk -Ft '{print $1, $2}' >Fix: See the attached patch adopted from NetBSD (PR/39133: cheusov at tut dot by: Don't treat -Ft as -F ). Patch attached with submission follows: diff -ru contrib/one-true-awk.orig/main.c contrib/one-true-awk/main.c --- contrib/one-true-awk.orig/main.c 2007-06-05 18:33:51.000000000 +0300 +++ contrib/one-true-awk/main.c 2010-01-30 12:06:16.000000000 +0200 @@ -53,6 +53,20 @@ int safe = 0; /* 1 => "safe" mode */ +static char * +setfs(char *p) +{ +#ifdef notdef + /* wart: t=>\t */ + if (p[0] == 't' && p[1] == 0) + return "\t"; + else +#endif + if (p[0] != 0) + return p; + return NULL; +} + int main(int argc, char *argv[]) { const char *fs = NULL; @@ -96,16 +110,11 @@ break; case 'F': /* set field separator */ if (argv[1][2] != 0) { /* arg is -Fsomething */ - if (argv[1][2] == 't' && argv[1][3] == 0) /* wart: t=>\t */ - fs = "\t"; - else if (argv[1][2] != 0) - fs = &argv[1][2]; + fs = setfs(argv[1] + 2); } else { /* arg is -F something */ argc--; argv++; - if (argc > 1 && argv[1][0] == 't' && argv[1][1] == 0) /* wart: t=>\t */ - fs = "\t"; - else if (argc > 1 && argv[1][0] != 0) - fs = &argv[1][0]; + if (argc > 1) + fs = setfs(argv[1]); } if (fs == NULL || *fs == '\0') WARNING("field separator FS is empty"); Only in contrib/one-true-awk: main.c.orig >Release-Note: >Audit-Trail: >Unformatted: