unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: John Mastro <john.b.mastro@gmail.com>
To: 23590@debbugs.gnu.org
Cc: Alex <agrambot@gmail.com>
Subject: bug#23590: 25.0.94; Errors in default lgrep command
Date: Fri, 22 Jul 2016 19:16:27 -0700	[thread overview]
Message-ID: <CAOj2CQR4WO6vsPu=GkydP7BpgjV9ppcbmjTjiHSyQ2TPHgDyag@mail.gmail.com> (raw)
In-Reply-To: <87futcp8wp.fsf@gmail.com>

Alex <agrambot@gmail.com> wrote:
> The default lgrep command (`all' for the FILES argument) gives
> off unexpected errors.
>
> * When there are no hidden (dot) files in the given directory, then I
>   get the following error:
>
> zsh:1: no matches found: *.
> Grep exited abnormally with code 1 at ...
>
> By default lgrep uses my default shell (zsh). Should this be the case?
> Setting `shell-file-name' to "bash" fixes this error, but it still
> produces the next error.

Thanks for reporting this. I've seen it too.

The problem seems to be caused by a difference in how zsh handles globs
that don't match anything, compared to bash. I'm not sure what the right
way would be to accommodate it in Emacs. Hopefully someone will be along
shortly with ideas for that. However, there are a couple things you can
do to work around it in the meantime.

First, you could change the command used by `lgrep' to enable zsh's
NULL_GLOB option, of which the zsh documentation[1] says: "If a pattern
for filename generation has no matches, delete the pattern from the
argument list instead of reporting an error". To do that, you could use
something like:

(with-eval-after-load 'grep
  (grep-apply-setting
   'grep-template
   "setopt null_glob; grep <X> <C> -n -e <R> <F>"))

Second, you could use advice on `lgrep' so that it invokes grep via bash
rather than zsh. That would look like:

(defun grep-use-bash (original &rest args)
  (let ((shell-file-name (executable-find "bash")))
    (apply original args)))

(with-eval-after-load 'grep
  (advice-add 'lgrep :around #'grep-use-bash))

I tested both options only briefly; apologies if I missed any issues.

> * When there are directories in the given directory (this includes . and
>   ..) then lgrep produces an error for each directory. For example:
>
>
> grep: .: Is a directory
> grep: ..: Is a directory
> grep: .emacs.d: Is a directory
>
> Grep exited abnormally with code 2 at ...

GNU Grep has an option (-d ACTION or --directories=ACTION) that can be
used to skip over directories (with "skip" as the ACTION), but it's not
in POSIX so I doubt we can use it in Emacs. If you know it will be
available on your system(s), you could add it to your `grep-template'
using the same technique as above.

[1] http://www.cs.elte.hu/zsh-manual/zsh_16.html

        John





  reply	other threads:[~2016-07-23  2:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-21  0:11 bug#23590: 25.0.94; Errors in default lgrep command Alex
2016-07-23  2:16 ` John Mastro [this message]
2016-07-23  7:45   ` Eli Zaretskii
2016-07-23 16:57     ` John Mastro
2016-07-23 17:15       ` Eli Zaretskii
2016-07-23 17:23         ` John Mastro
2016-07-23 17:58           ` Eli Zaretskii
2016-07-23 19:52             ` Glenn Morris
2016-07-23 17:28     ` Alex
2016-07-23 18:00       ` Eli Zaretskii
2016-07-23 18:18         ` Eli Zaretskii
2016-07-23 22:12           ` Alex
2020-09-04 14:09             ` Lars Ingebrigtsen
2020-10-07  3:41               ` Lars Ingebrigtsen
2020-10-07  8:17                 ` Eli Zaretskii
2020-10-09  4:15                   ` Lars Ingebrigtsen
2020-10-13 20:09                     ` Juri Linkov
2020-10-14  4:10                       ` Lars Ingebrigtsen
2016-07-23 17:11   ` Alex

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAOj2CQR4WO6vsPu=GkydP7BpgjV9ppcbmjTjiHSyQ2TPHgDyag@mail.gmail.com' \
    --to=john.b.mastro@gmail.com \
    --cc=23590@debbugs.gnu.org \
    --cc=agrambot@gmail.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).