Bug 77466 - grep recursive directory loop reporting outputs extra newline in 6-CURRENT.
Summary: grep recursive directory loop reporting outputs extra newline in 6-CURRENT.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-13 22:00 UTC by Andre Guibert de Bruet
Modified: 2005-02-13 23:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Guibert de Bruet 2005-02-13 22:00:39 UTC
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.

Fix: 

I have a patch that addresses the issue. It is up at http://bling.properkernel.com/freebsd/grep.recursive.patch .
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
Comment 1 David E. O'Brien freebsd_committer freebsd_triage 2005-02-13 23:07:44 UTC
State Changed
From-To: open->closed

Committed thanks. 
BTW, please use unified diffs (diff -u).