Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


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 $?

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 $?

so it does seems to be something with xargs.

share|improve this question
M-x rgrep runs find … | xargs grep …, and 123 means that at least one of xargs's invocations of grep returned a non-zero error code. If this happens only in large code bases, it might be related to xargs invoking more than one instance of grep (perhaps one instance finds no file?). Is a *grep* buffer created? – Gilles Oct 7 '10 at 23:00
it does open the grep buffer even shows a bunch of results and then prints "Grep exited abnormally with code 123 at ..." – Mcradle Oct 8 '10 at 14:51
up vote 9 down vote accepted

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

   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
share|improve this answer

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

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.

share|improve this answer
Thanks Andy. I have ack installed but never came around to download and install ack.el for emacs, I might do eventually. – Mcradle Oct 9 '10 at 0:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .