How to use cscope with paths that contain spaces
Asked Answered
I

4

9

There are some folder that contains space, and as a result, those folders can not be indexed using cscope.

Can i ask you for help to solve this,or any suggestion.

thanks Julius


Thanks for your reply.

My steps to use cscope like the following

  • find . -name '*.scala'>cscope.files
  • cscope -b
    at this step. i see the message indicates that can not find file:
    cscope: cannot find file /work/project/copy
    cscope: cannot find file of
    cscope: cannot find file fp/src/main/jav....
    Actually copy of fp is a folder.so i think cscope can not recognize the folder contains space.

I encountered this problem when i tried to use vim with cscope.maybe i need move this question to other tag.

Irascible answered 7/7, 2010 at 16:19 Comment(1)
You used the Vim tag. Is this because you are trying to use the :cscope commands within Vim? If so, can you show the commands that you are trying and what errors you are getting?Womb
L
8

You can do it simply using GNU find at least, you can use the -printf or -fprintf options for that:

find . -type f -fprintf cscope.files '"%p"\n'
Lancey answered 14/5, 2014 at 17:53 Comment(2)
simplify %h/%f to %pYiyid
Yours is the fastest answer: 8% faster than mine, 14% faster than with sed . . . and 1000x as fast as with exec!Yiyid
Y
4

pydave's answer is very slow. This way took 0.10s where pydave's answer took 14s:

find . -name "*.scala" | awk '{print "\""$0"\""}' > cscope.files
Yiyid answered 14/4, 2014 at 22:2 Comment(1)
Kudos! Works really fastPastor
C
2

You can use find's -exec to force quotes around your output:

find . -name "*.scala" -exec echo \"{}\" \; > cscope.files

You might need to mess around with quoting/escaping if you're doing this from a script.

Carolinacaroline answered 31/8, 2011 at 17:25 Comment(2)
This answer takes ~1 second to do ~100 files. My answer takes ~1 second to do ~100,000 files.Yiyid
@webb: Using fprintf (Olivier Diotte's answer) certainly seems like a better use of find than my naive proposal.Carolinacaroline
M
0

Double quoting the files names works in cygwin, where as escaping with backslash does not.

$ find $PWD -name "*.scala" | sed -e 's/^/"/g' -e 's/$/"/g' > cscope.files
Moneylender answered 4/3, 2014 at 15:8 Comment(1)
sed 's/.*/"&"/' is slightly fasterYiyid

© 2022 - 2024 — McMap. All rights reserved.