Bug 77278 - grep component fails to search with spaces in path
Summary: grep component fails to search with spaces in path
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: 3.0.1
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: KDevelop Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-11 13:01 UTC by Michal Ceresna
Modified: 2004-03-29 20:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Ceresna 2004-03-11 13:01:37 UTC
Version:           3.0.1 (using KDE KDE 3.1.5)
Installed from:    Debian testing/unstable Packages
Compiler:          gcc version 3.3.3 (Debian) 
OS:          Linux

when running grep in a directory which has spaces in path errors occur
e.g. for /home/ceresna/te st1/test2:

st1/test2: No such file or directory
st1/test2: No such file or directory
st1/test2: No such file or directory

 
this patch solves the problem:

--- kdevelop3-3.0.1.orig/parts/grepview/grepviewwidget.cpp      2004-01-27 23:30:59.000000000 +0100
+++ kdevelop3-3.0.1/parts/grepview/grepviewwidget.cpp   2004-03-10 10:39:40.000000000 +0100
@@ -205,6 +205,10 @@
         command += "| grep -v \"SCCS/\" ";
         command += "| grep -v \"CVS/\" ";
     }
+
+    // quote spaces in filenames going to xargs
+    command += "| sed \"s/ /\\\\\\ /g\" ";
+
     command += "| xargs " ;

 #ifndef USE_SOLARIS
Comment 1 Jens Dagerbo 2004-03-11 17:00:38 UTC
A quick test says you're right.. strange no one had noticed before. Patch applied to HEAD, will backport if no problems appear.
Comment 2 Jens Dagerbo 2004-03-11 17:00:51 UTC
CVS commit by dagerbo: 

Fix bug #77278. Patch by Michal Ceresna.

CCMAIL: 77278-done@bugs.kde.org


  M +5 -1      grepviewwidget.cpp   1.30


--- kdevelop/parts/grepview/grepviewwidget.cpp  #1.29:1.30
@@ -196,4 +196,8 @@ void GrepViewWidget::searchActivated()
         command += "| grep -v \"CVS/\" ";
     }
+
+    // quote spaces in filenames going to xargs 
+    command += "| sed \"s/ /\\\\\\ /g\" "; 
+
     command += "| xargs " ;
 
@@ -240,5 +244,5 @@ void GrepViewWidget::slotExecuted(QListB
     GrepListBoxItem *gi = static_cast<GrepListBoxItem*>(i);
     m_part->partController()->editDocument( KURL( gi->filename() ), gi->linenumber()-1 );
-    m_part->mainWindow()->lowerView(this);
+//    m_part->mainWindow()->lowerView(this);
 }
 


Comment 3 Jens Dagerbo 2004-03-29 20:25:31 UTC
CVS commit by dagerbo: 

Fix bug #77278. Patch by Michal Ceresna.

CCMAIL: 77278@bugs.kde.org


  M +6 -2      grepviewwidget.cpp   1.25.2.3


--- kdevelop/parts/grepview/grepviewwidget.cpp  #1.25.2.2:1.25.2.3
@@ -196,4 +196,8 @@ void GrepViewWidget::searchActivated()
         command += "| grep -v \"CVS/\" ";
     }
+
+    // quote spaces in filenames going to xargs 
+    command += "| sed \"s/ /\\\\\\ /g\" "; 
+
     command += "| xargs " ;
 
@@ -239,6 +243,6 @@ void GrepViewWidget::slotExecuted(QListB
 
     GrepListBoxItem *gi = static_cast<GrepListBoxItem*>(i);
-    m_part->partController()->editDocument( gi->filename(), gi->linenumber()-1 );
-    m_part->mainWindow()->lowerView(this);
+    m_part->partController()->editDocument( KURL( gi->filename() ), gi->linenumber()-1 );
+//    m_part->mainWindow()->lowerView(this);
 }