Subject: Re: bug#70507: 30.0.50; eshell: grep -H and -n flags are hardcoded and the latter cannot be overwritten

From: Jim Porter <[email-masked]>
Date: Mon, 20 May 2024 13:52:29 -0700

On 5/20/2024 1:18 PM, Stefan Kangas wrote:
> Jose A Ortega Ruiz <[email-masked]> writes:
> 
>> I've noticed that -Hn flags are hardcoded when calling eshell's grep
>> command. Specially in pipes, where -H prints a noisy (standard input)
>> prefix for every line, those flags are rarely what I personally want,
>> and I'd like to have the option to disable them. For -H i can add -h to
>> the call, or even redefine eshell/grep to not use -H, but there's no
>> flag to disable -n.
> 
> Jim, any comments on the above bug report?

It would probably be reasonable to define some new 
'eshell-grep-default-interactive-flags' variable, defaulting to "-nH" 
and only taking effect when being redirected to a compilation buffer. 
Maybe 'eshell-compile' could also take an EXTRA-ARGS argument that holds 
extra args to use. There are a few edge cases here I haven't fully 
though through, so maybe this is all wrong.

In the short term though, you have a few options:

1. "alias grep '*grep $@*'": This just makes "grep" always use the real 
"grep" program on your computer, with no fancy compilation buffers.

2. "alias grep 'compile --mode=grep-mode grep $@*'": This ensures that 
"grep" opens in a compilation buffer when called interactively (and not 
in a pipeline, etc), but only with the flags you explicitly specify.