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

From: Alex <[email-masked]>
Date: Sat, 23 Jul 2016 11:28:21 -0600

Eli Zaretskii <[email-masked]> writes:

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

shell-file-name is set to zsh (as it's my default user shell) in emacs
-Q as well. This can be useful for commands like ansi-term. If an Emacs
program expects full sh compatibility, then perhaps there could be an
extra variable they can check before falling back to shell-file-name?

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

When I use lgrep I already know that I'm not going to be searching
directories. I find such messages to be useless clutter.

Additionally, while zsh doesn't error on this part (with the workarounds
that John provided), bash does appear to error because it is including
directories:

Grep exited abnormally with code 2 at ...

PS:

I noticed that between 25.0.94 and 25.0.95 the default command changes
slightly. It now includes a wildcard ..?* that bash doesn't seem to like
if there are no matching files:

grep: ..?*: No such file or directory

Grep exited abnormally with code 2 at ...