From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#16045: 24.3.50; rgrep can't work Date: Wed, 04 Dec 2013 19:24:07 +0200 Message-ID: <8338m84jig.fsf@gnu.org> References: <201312041357404213761@163.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1386177915 20153 80.91.229.3 (4 Dec 2013 17:25:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Dec 2013 17:25:15 +0000 (UTC) Cc: 16045@debbugs.gnu.org To: Michael Albinus , zijianyue Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 04 18:25:20 2013 Return-path: Envelope-to: geb-bug-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 1VoGCN-0002sp-5H for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Dec 2013 18:25:19 +0100 Original-Received: from localhost ([::1]:49538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoGCM-0005Cl-PM for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Dec 2013 12:25:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoGCD-0004yp-5X for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2013 12:25:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoGC6-0008Rs-IB for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2013 12:25:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoGC6-0008Ra-FM for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2013 12:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VoGC5-0003sv-VS for bug-gnu-emacs@gnu.org; Wed, 04 Dec 2013 12:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Dec 2013 17:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16045 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16045-submit@debbugs.gnu.org id=B16045.138617785414871 (code B ref 16045); Wed, 04 Dec 2013 17:25:01 +0000 Original-Received: (at 16045) by debbugs.gnu.org; 4 Dec 2013 17:24:14 +0000 Original-Received: from localhost ([127.0.0.1]:58249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VoGBJ-0003rm-SU for submit@debbugs.gnu.org; Wed, 04 Dec 2013 12:24:14 -0500 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:62487) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VoGBG-0003re-VJ for 16045@debbugs.gnu.org; Wed, 04 Dec 2013 12:24:12 -0500 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MXA00600LKA9N00@a-mtaout23.012.net.il> for 16045@debbugs.gnu.org; Wed, 04 Dec 2013 19:24:09 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MXA006J5LO94470@a-mtaout23.012.net.il>; Wed, 04 Dec 2013 19:24:09 +0200 (IST) In-reply-to: <201312041357404213761@163.com> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:81376 Archived-At: > Date: Wed, 4 Dec 2013 13:57:45 +0800 > From: zijianyue > > Hello,rgrep worked well before I use this version 24.3.50. > Now,rgrep always found nothing in emacs,lgrep works well.I don't know why. Michael, this is due to this commit of yours (almost a year ago!): revno: 111276 committer: Michael Albinus branch nick: trunk timestamp: Thu 2012-12-20 11:15:38 +0000 message: * progmodes/grep.el (rgrep): Escape command line. Sometimes, it is too long for Tramp. See discussion in . * progmodes/compile.el (compilation-start): Remove line escape template. Command lines with newlines are non-portable: Windows shells don't support them, and don't treat backslashes specially anyway (that's why we have shell-quote-argument). So what that change did on Windows is add literal \r\n strings to the command, making it wrong at best and un-parsable at worst. Since the original problem was with Tramp, i.e. with remote files, I suggest the patch below; it worked for me on Windows. Please see if there's anything wrong with it; if not, I will commit. Btw, I cannot say I like the fact that the command displayed in the *grep* buffer is different from what is actually passed to the shell. It makes debugging much harder when some error occurs. In my case, 'find' displayed several warnings like this: find: warning: Filenames usually don't contain slashes (though pathnames do). That means that '-name .#*\ ' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ .#*\ '. and I stared at this for several minutes trying to figure out what the heck was it talking about, since the command displayed in the buffer had no backslashes at all. I needed to look at the command line in GDB to see what is actually being sent. So I think this is not a good idea at all. Here's the patch I suggest: === modified file 'lisp/progmodes/grep.el' --- lisp/progmodes/grep.el 2013-05-24 20:54:38 +0000 +++ lisp/progmodes/grep.el 2013-12-04 17:10:42 +0000 @@ -1005,7 +1005,9 @@ to specify a command to run." (mapconcat #'shell-quote-argument (split-string files) - (concat "\\\n" " -o " find-name-arg " ")) + (concat + (if (file-remote-p dir) "\\\n") + " -o " find-name-arg " ")) " " (shell-quote-argument ")")) dir @@ -1026,7 +1028,9 @@ to specify a command to run." (concat "*/" (cdr ignore))))))) grep-find-ignored-directories - "\\\n -o -path ") + (if (file-remote-p dir) + "\\\n -o -path " + " -o -path ")) " " (shell-quote-argument ")") " -prune -o ")) @@ -1044,7 +1048,9 @@ to specify a command to run." (shell-quote-argument (cdr ignore)))))) grep-find-ignored-files - "\\\n -o -name ") + (if (file-remote-p dir) + "\\\n -o -name " + " -o -name ")) " " (shell-quote-argument ")") " -prune -o "))))))