all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Michael Albinus <michael.albinus@gmx.de>, zijianyue <zijianyue@163.com>
Cc: 16045@debbugs.gnu.org
Subject: bug#16045: 24.3.50; rgrep can't work
Date: Wed, 04 Dec 2013 19:24:07 +0200	[thread overview]
Message-ID: <8338m84jig.fsf@gnu.org> (raw)
In-Reply-To: <201312041357404213761@163.com>

> Date: Wed, 4 Dec 2013 13:57:45 +0800
> From: zijianyue <zijianyue@163.com>
> 
>   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 <michael.albinus@gmx.de>
  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
    <http://thread.gmane.org/gmane.emacs.tramp/8233/focus=8244>.

    * 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 "))))))






  reply	other threads:[~2013-12-04 17:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04  5:57 bug#16045: 24.3.50; rgrep can't work zijianyue
2013-12-04 17:24 ` Eli Zaretskii [this message]
2013-12-04 19:10   ` Stefan Monnier
2013-12-04 19:36     ` Eli Zaretskii
2013-12-04 20:52       ` Stefan Monnier
2013-12-05 15:10     ` Michael Albinus
2013-12-05 17:55       ` Eli Zaretskii
2013-12-05 19:58         ` Michael Albinus
2013-12-05 20:23           ` Eli Zaretskii
2013-12-05 20:50             ` Michael Albinus
2013-12-05 21:09           ` Stefan Monnier
2013-12-06 15:39             ` Michael Albinus
2013-12-06 15:58               ` Eli Zaretskii
2013-12-06 16:15                 ` Michael Albinus
2013-12-09  5:23                   ` bug#16045: 回复: " zijianyue
2013-12-09  7:20                     ` Michael Albinus
2013-12-06  9:12         ` Andreas Schwab
2013-12-06  9:16           ` Andreas Schwab
2013-12-05 15:14   ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8338m84jig.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=16045@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=zijianyue@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.