Grep exits abnormally with code 123 when running rgrep on emacs
Greetings fellow Emacsers
I'm running GNU Emacs 23.1.1 on "Ubuntu 10.04.1 LTS" and any search I perform using the built-in M-x rgrep on the standard Linux kernel source code (vanilla) ends prematurely with the following error printed to the emacs echo area:
Grep exited abnormally with code 123
I have been seeing it for a while on Redhat systems as well, and with other (large) code bases, Anybody seen or even better cured that?
Thanks!
Edit: for reasons beyond me stackexchange does not allow me to edit my comment below so I'll update here.
following the comment below I have tried to run the same command that rgrep runs in an emacs shell buffer
find . \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/MCVS -o -path \*/.svn -o -path \*/.git
-o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -prune -o -type f \( -name \*.\[ch\] \) -p
rint0 | xargs -0 -e grep -i -nH -e v4l_compat_ioctl32
while it does not print any error, interrogating the exit code shows the same 123 again.
/home/mcradle/linux> echo $?
123
following the comment from Gilles I've tried to run
/home/mcradle/linux> find . -type f \( -name \*.\[ch\] \) -exec grep -i -nH -e v4l_compat_ioctl32 '{}' \;
which is functionally equivalent to the find and xargs combination and it completed with exit code 0
/home/mcradle/linux> echo $?
0
so it does seems to be something with xargs.
Looking at xargs exit code documentation:
123 if any invocation of the command exited with status 1-125
but according to grep documentation 1 is the exit status if grep didn't match the pattern
EXIT STATUS
Normally, the exit status is 0 if selected lines are found and 1 otherwise.
So to me it seems that the command line that emacs uses to issue an 'rgrep' search will always return 123, and this error either needs to be suppressed or replaced with a command line such as
find . -type f \( -name \*.\[ch\] \) -exec grep -i -nH -e v4l
It looks like you're trying to do a recursive grep through a bunch of C .c and .h files, while ignoring directories used by version control systems. You want ack. See http://betterthangrep.com/
The command to do exactly what you are doing, in ack:
ack --cc -i v4l_compat_ioctl32
The effects of -r, -n and -H are assumed in ack. The -i is still case-insensitive, and --cc says "Search *.c and *.h files only"
No need for find. No need for xargs. Just a version of Perl installed and a single Perl program, with no external modules.