From nobody@FreeBSD.org  Sun Feb 13 21:53:26 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0654716A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Feb 2005 21:53:26 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id C05BB43D41
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Feb 2005 21:53:25 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j1DLrPgO085971
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 13 Feb 2005 21:53:25 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j1DLrP5I085942;
	Sun, 13 Feb 2005 21:53:25 GMT
	(envelope-from nobody)
Message-Id: <200502132153.j1DLrP5I085942@www.freebsd.org>
Date: Sun, 13 Feb 2005 21:53:25 GMT
From: Andre Guibert de Bruet <andy@siliconlandmark.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: grep recursive directory loop reporting outputs extra newline in 6-CURRENT.
X-Send-Pr-Version: www-2.3

>Number:         77466
>Category:       bin
>Synopsis:       grep recursive directory loop reporting outputs extra newline in 6-CURRENT.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 13 22:00:39 GMT 2005
>Closed-Date:    Sun Feb 13 23:07:56 GMT 2005
>Last-Modified:  Sun Feb 13 23:07:56 GMT 2005
>Originator:     Andre Guibert de Bruet
>Release:        6.0-CURRENT
>Organization:
Silicon Landmark 
>Environment:
FreeBSD bling.home 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Sat Feb 12 02:21:11 EST 2005     root@bling.home:/usr/CURRENT/sys/i386/compile/BLING  i386
>Description:
grep has built-in directory loop reporting that is enabled when using the -R (recursive) option. CURRENT (5.3 too?) outputs an extra newline character when such a directory loop is detected. This behavior is not found in FreeBSD 4.x. Additionally, it breaks scripts that depend upon the traditional behavior.
>How-To-Repeat:
$ grep -R somethingreallylongthatyouwillnotfind /usr/src                                                                                                                
grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/3dfx/@: recursive directory loop

grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/aac/aac_linux/@: recursive directory loop

grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/aac/@: recursive directory loop

grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/accf_data/@: recursive directory loop

grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/accf_http/@: recursive directory loop
[snip]

With the patch, you do not get the extra newline:

$ grep -R somethingreallylongthatyouwillnotfind /usr/src                                                                                                                
grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/3dfx/@: recursive directory loop
grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/aac/aac_linux/@: recursive directory loop
grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/aac/@: recursive directory loop
grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/accf_data/@: recursive directory loop
grep: warning: /usr/src/sys/i386/compile/BLING/modules/usr/CURRENT/sys/modules/accf_http/@: recursive directory loop

>Fix:
I have a patch that addresses the issue. It is up at http://bling.properkernel.com/freebsd/grep.recursive.patch .
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: obrien 
State-Changed-When: Sun Feb 13 23:07:44 GMT 2005 
State-Changed-Why:  
Committed thanks. 
BTW, please use unified diffs (diff -u). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77466 
>Unformatted:
