Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cscope for files which are symlinks

I have a source directory with several files. Some of them are symlinks to other files.

I created a cscope.files file. But when I execute cscope. It complains for the files that are symlinks:

cscope: cannot find file /home/bla/source/file.cc

I think it's not very good, but maybe the correct way to go is to change the "find" script, to just write the destination of the symlink instead?

like image 598
user972014 Avatar asked Apr 08 '15 15:04

user972014


People also ask

How do I bypass symlinks?

Overwriting Symlinks If you try to create a symbolic link that already exists , the ln command will print an error message. To overwrite the destination path of the symlink, use the -f ( --force ) option.

Does FAT32 support symlinks?

Bookmark this question. Show activity on this post. I know FAT32, as well as FAT16/12 neither support symbolic links nor hard-links.

Which command follows symlinks?

In order to follow symbolic links, you must specify ls -L or provide a trailing slash. For example, ls -L /etc and ls /etc/ both display the files in the directory that the /etc symbolic link points to. Other shell commands that have differences due to symbolic links are du, find, pax, rm and tar.


2 Answers

Currently I'm using:

# Write only the files which are NOT symlinks
find `pwd` \( \( -iname "*.c" -o -iname "*.cc" -o -iname "*.h" \) -and \( -not -type l \) \) -print > cscope.files
# Add the target of the symlink for all files matching the right extension, and are symlinks
find `pwd` \( \( -iname "*.c" -o -iname "*.cc" -o -iname "*.h" \) -and -type l \) -printf "%l\n"  >> cscope.files

But this seems like a terrible solution. Still looking for a better one

like image 187
user972014 Avatar answered Sep 30 '22 04:09

user972014


I think you can use the command to find all real paths in a folder that you searched

find -L [your searched folder] -name [your searched pattern] -exec realpath {} \; >> cscope.files

For example, if I would like to add developed folder and linux kernel header to cscope.files, I will the these commands:

find -L `pwd` -iname "*.c" -o -iname "*.h" > cscope.files
find -L /usr/src/linux-headers-3.19.0-15-generic/ -iname '*.h' -exec realpath {} \; >> cscope.files

I hope the answer can help you.

like image 34
Iverson Hsieh Avatar answered Sep 30 '22 06:09

Iverson Hsieh