erig0 / cscope_dynamic

Automatic dynamic cscope updates for Vim
25 stars 12 forks source link

fix find invocation (apply "-type" to all searched suffixes) #5

Closed nalajcie closed 4 years ago

nalajcie commented 4 years ago

Previous find invocation applied -type f only to the last name wildcard (part after last -or").

This patch fixes it by using the correct find syntax.

Testcase:

$ mkdir -p  search/dir.c search/dir.h; touch search/file.c search/file.h
$ find search -name \*.c -or -name \*.h -type f
search/dir.c
search/file.h
search/file.c

The search/dir.c result is invalid.

$ find search -type f \( -name \*.c -or -name \*.h \)
search/file.h
search/file.c

Additionally, the stderr output is redirected to /dev/null to avoid mangling vim screen in case some directories in the search path are not accessible by the user, eg:

$ chmod 400 search
$ find search -name \*.c -or -name \*.h -type f
find: 'search/dir.c': Permission denied
search/dir.c
find: 'search/dir.h': Permission denied
search/file.h
search/file.c
$ find search -name \*.c -or -name \*.h -type f 2>/dev/null
search/dir.c
search/file.h
search/file.c
erig0 commented 4 years ago

Thanks for the quality PR and description!