all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 32093@debbugs.gnu.org
Subject: bug#32093: 27.0.50; M-x grep appends /dev/null to command line
Date: Sun, 08 Jul 2018 13:17:53 +0200	[thread overview]
Message-ID: <87d0vydli6.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <87lgamavq7.fsf@gmx.de> (Michael Albinus's message of "Sun, 08 Jul 2018 12:05:20 +0200")

Michael Albinus <michael.albinus@gmx.de> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> So you are saying there is a bug workaround that will tie me into using
>> one grep-like command in future, ever.  Because obviously in my case
>> auto detection failed.
>
> Don't know. Maybe you check what autodetect does in your case.

Here is the respective code:

318e2976570 (Kim F. Storm            2003-11-23  626)     (unless (or (not grep-use-null-device) (eq grep-use-null-device t))
318e2976570 (Kim F. Storm            2003-11-23  627)       (setq grep-use-null-device
318e2976570 (Kim F. Storm            2003-11-23  628) 	    (with-temp-buffer
318e2976570 (Kim F. Storm            2003-11-23  629) 	      (let ((hello-file (expand-file-name "HELLO" data-directory)))
318e2976570 (Kim F. Storm            2003-11-23  630) 		(not
0acfb7cea68 (Kim F. Storm            2006-04-28  631) 		 (and (if grep-command
318e2976570 (Kim F. Storm            2003-11-23  632) 			  ;; `grep-command' is already set, so
318e2976570 (Kim F. Storm            2003-11-23  633) 			  ;; use that for testing.
0acfb7cea68 (Kim F. Storm            2006-04-28  634) 			  (grep-probe grep-command
0acfb7cea68 (Kim F. Storm            2006-04-28  635) 				      `(nil t nil "^English" ,hello-file)
0acfb7cea68 (Kim F. Storm            2006-04-28  636) 				      #'call-process-shell-command)
318e2976570 (Kim F. Storm            2003-11-23  637) 			;; otherwise use `grep-program'
0acfb7cea68 (Kim F. Storm            2006-04-28  638) 			(grep-probe grep-program
0acfb7cea68 (Kim F. Storm            2006-04-28  639) 				    `(nil t nil "-nH" "^English" ,hello-file)))
318e2976570 (Kim F. Storm            2003-11-23  640) 		      (progn
318e2976570 (Kim F. Storm            2003-11-23  641) 			(goto-char (point-min))
318e2976570 (Kim F. Storm            2003-11-23  642) 			(looking-at
318e2976570 (Kim F. Storm            2003-11-23  643) 			 (concat (regexp-quote hello-file)
318e2976570 (Kim F. Storm            2003-11-23  644) 				 ":[0-9]+:English")))))))))

So the procedure is that the proposed command line (taken from
grep-program) does not include -nH .  User edits it to turn it into "git
grep".  Autodetection tries calling this(?) on the hello-file(?) which
fails due to the hello-file not being in the Git repository.  As a
result, Emacs decides to use /dev/null (?).

This code actually is considerably old, older than what I remember
having worked (though it's sort of hard to tell since the results of
autodetection are stored in a session).  So I consider it more likely
that the more recent

644cdd1aa0a (Noam Postavsky          2016-09-13  646)     (when (eq grep-use-null-filename-separator 'auto-detect)
644cdd1aa0a (Noam Postavsky          2016-09-13  647)       (setq grep-use-null-filename-separator
644cdd1aa0a (Noam Postavsky          2016-09-13  648)             (with-temp-buffer
644cdd1aa0a (Noam Postavsky          2016-09-13  649)               (let* ((hello-file (expand-file-name "HELLO" data-directory))
644cdd1aa0a (Noam Postavsky          2016-09-13  650)                      (args `("--null" "-ne" "^English" ,hello-file)))
644cdd1aa0a (Noam Postavsky          2016-09-13  651)                 (if grep-use-null-device
644cdd1aa0a (Noam Postavsky          2016-09-13  652)                     (setq args (append args (list null-device)))
644cdd1aa0a (Noam Postavsky          2016-09-13  653)                   (push "-H" args))
644cdd1aa0a (Noam Postavsky          2016-09-13  654)                 (and (grep-probe grep-program `(nil t nil ,@args))
644cdd1aa0a (Noam Postavsky          2016-09-13  655)                      (progn
644cdd1aa0a (Noam Postavsky          2016-09-13  656)                        (goto-char (point-min))
644cdd1aa0a (Noam Postavsky          2016-09-13  657)                        (looking-at
644cdd1aa0a (Noam Postavsky          2016-09-13  658)                         (concat (regexp-quote hello-file)
644cdd1aa0a (Noam Postavsky          2016-09-13  659)                                 "\0[0-9]+:English"))))))))
644cdd1aa0a (Noam Postavsky          2016-09-13  660) 

is involved here.  At any rate, the principal problem here is that "git
grep" is a grep-like command that will usually refuse to work on
out-of-tree files (unless --no-index option is given).  So the results
from any of the autodetection, based on searching the HELLO file, are
sort-of random.

-- 
David Kastrup





  reply	other threads:[~2018-07-08 11:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-08  9:33 bug#32093: 27.0.50; M-x grep appends /dev/null to command line David Kastrup
2018-07-08  9:51 ` Michael Albinus
2018-07-08  9:53   ` David Kastrup
2018-07-08 10:05     ` Michael Albinus
2018-07-08 11:17       ` David Kastrup [this message]
2018-07-08 12:19         ` Noam Postavsky
2018-07-08 12:30           ` David Kastrup
2018-07-08 19:04           ` Eli Zaretskii
2018-07-08 19:11             ` David Kastrup
2018-07-09 21:43             ` Noam Postavsky
2018-07-10  7:33               ` David Kastrup
2018-07-10 15:55               ` Eli Zaretskii
2018-07-10 22:04                 ` Noam Postavsky
2018-07-09 23:10             ` Noam Postavsky

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=87d0vydli6.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=32093@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    /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.