Subject: bug#23590: 25.0.94; Errors in default lgrep command

From: Eli Zaretskii <[email-masked]>
Date: Sat, 23 Jul 2016 10:45:10 +0300

> From: John Mastro <[email-masked]>
> Date: Fri, 22 Jul 2016 19:16:27 -0700
> Cc: Alex <[email-masked]>
> 
> Alex <[email-masked]> 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.

Shell commands that Emacs emits support /bin/sh and compatible
shells.  Zsh's default treatment of unmatched wildcards isn't.

I don't know how it happened that lgrep invokes zsh on OP's system,
but if that is due to user customizations, they should be corrected.
If that is Emacs's fault (i.e. Emacs invokes zsh without any
customizations), it should be fixed.

> > * 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.

Yes, but I don't understand why the OP says these are errors.  They
aren't; they are just informative messages from Grep.