From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Proulx Newsgroups: gmane.emacs.help Subject: Re: Grep exited abnormally with code 123 Date: Tue, 16 Apr 2013 15:08:15 -0600 Message-ID: <20130416210815.GA7232@hysteria.proulx.com> References: <83a9oy47f6.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1366146515 14632 80.91.229.3 (16 Apr 2013 21:08:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Apr 2013 21:08:35 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 16 23:08:39 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1USD7G-0002XJ-Im for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Apr 2013 23:08:38 +0200 Original-Received: from localhost ([::1]:39827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USD7F-0008S8-QN for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Apr 2013 17:08:37 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USD73-0008Rx-D7 for help-gnu-emacs@gnu.org; Tue, 16 Apr 2013 17:08:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USD71-0002kC-63 for help-gnu-emacs@gnu.org; Tue, 16 Apr 2013 17:08:25 -0400 Original-Received: from joseki.proulx.com ([216.17.153.58]:49606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USD70-0002ia-Ko for help-gnu-emacs@gnu.org; Tue, 16 Apr 2013 17:08:23 -0400 Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 5D542211DA for ; Tue, 16 Apr 2013 15:08:16 -0600 (MDT) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id 05CA42DCE6; Tue, 16 Apr 2013 15:08:15 -0600 (MDT) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <83a9oy47f6.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 216.17.153.58 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90199 Archived-At: Eli Zaretskii wrote: > > Andrew Pennebaker wrote: > > Often, M-x rgrep terminates early with this message in the minibuffer: > > > > Grep exited abnormally with code 123 > > According to this: > > http://superuser.com/questions/197031/grep-exits-abnormally-with-code-123-when-running-rgrep-on-emacs > > this is "normal" (well, everything except the message). It is normal. It just means that there were no grep hits. If there were grep hits then it would exit 0. No grep hits and it is reporting 123. It is a grep feature. You are probably using emacs 23. Emacs 23 uses find piped to xargs to run grep. That is an obsolete way of running it. Emacs 24 now defaults to using only find to run grep. And in 24 if there are no grep hits the return is captured and "Grep:exit [no match]" is displayed instead of a non-zero exit code. Therefore what you are complaining about is already improved in the next version. To understand where the 123 comes from start looking at the grep documentation. man grep EXIT STATUS The exit status is 0 if selected lines are found, and 1 if not found. If an error occurred the exit status is 2. (Note: POSIX error handling code should check for '2' or greater.) If there are no matches then grep exits 1. The xargs command exit status is: man xargs EXIT STATUS xargs exits with the following status: 0 if it succeeds 123 if any invocation of the command exited with status 1-125 124 if the command exited with status 255 125 if the command is killed by a signal 126 if the command cannot be run 127 if the command is not found 1 if some other error occurred. Exit codes greater than 128 are used by the shell to indicate that a program died due to a fatal signal. And since grep exits 1 with no matches then xargs exits 123 as documented in the above table. Emacs 23 and earlier: find . -type f -print0 | xargs -0 -e grep -nH -e PATTERN Emacs 24: find . -type f -exec grep -nH -e PATTERN {} + > Perhaps consider submitting a bug report. Since it has already been addressed with a later version I would simply update the default grep-find pattern to the new find-only style. Then it will be solved now. Or upgrade to emacs 24. :-) Or just understand that exit 123 means no grep matches. You can customize the grep-find-command. The v24 help for it says: grep-find-command is a variable defined in `grep.el'. Its value is ("find . -type f -exec grep -nH -e {} +" . 34) Original value was nil This variable may be risky if used as a file-local variable. Documentation: The default find command for M-x grep-find. In interactive usage, the actual value of this variable is set up by `grep-compute-defaults'; to change the default value, use Customize or call the function `grep-apply-setting'. Bob