On 03/21/2017 10:39 AM, Thomas Güttler wrote: > > * Strategy 1: GREP_OPTIONS. But this is deprecated. See > http://www.gnu.org/software/grep/manual/html_node/Environment-Variables.html > > * Stragegy 2: GREP_COLORS look like a solution at the first sight, but > this does something different. > * Strategy 3: alias. This does not work for `find ... | xargs grep`, > since xargs does not evaluate aliases.
It can if you teach it to (assuming you are using a sh-like shell): alias xargs='xargs ' (I can't help you if you are using a csh-like shell) > * Strategy 4: Write a simple wrapper script. No, I think this is too > dirty and makes more trouble than it solves. What trouble does it cause? This our preferred recommendation, by the way. > * Strategy 5: patch the source code - No Why not? It's open source, so you are free to do so, for your local setup. > * Strategy 6: Contact grep developers, ask for a replacement of > GREP_OPTIONS Which you've done. But it won't help, because we made a conscious decision to kill environment variables that have the chance of breaking scripts, and we are unlikely to be persuaded to change our minds. > Why is GREP_OPTIONS deprecated? Because it has the tendency to break unsuspecting scripts that don't sanitize GREP_OPTIONS out of their environment. Environment variables that change default output are very dangerous. Environment variables that only modify behavior that has to be opted into (like GREP_COLORS) are not as bad, but once you are explicitly opting into something, a wrapper script is a lot more direct than a wrapper script + an environment variable. > > I guess this can do confusing things if you exclude directories via this > environment variable. Yes, that was one of the things known to break scripts. > > But setting color=auto looks like something which does not do harm. You're right that 'color=auto' tends to not break scripts, but 'color=always' does, and it gets rather hard, rather fast, if you try to special-case WHICH aspects of GREP_OPTIONS are safe, vs. just a blanket statement that GREP_OPTIONS is in general unsafe. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature