{"id":2564,"date":"2012-01-24T21:57:01","date_gmt":"2012-01-24T19:57:01","guid":{"rendered":"http:\/\/mummila.net\/kommentit\/?p=2564"},"modified":"2012-01-24T21:57:01","modified_gmt":"2012-01-24T19:57:01","slug":"ignores-coloralways-in-grep_options","status":"publish","type":"post","link":"https:\/\/mummila.net\/kommentit\/2012\/01\/24\/ignores-coloralways-in-grep_options\/","title":{"rendered":"Ignores &#8211;color=always in GREP_OPTIONS"},"content":{"rendered":"<p>(Doing this in reverse order, as I think the steps are best represented by what I actually type in.)<\/p>\n<p>Premise:<br \/>\nI&#8217;m a newbie who tries to do the nasty and make grep output always colored using GREP_OPTIONS. I have a file called test, with numbers 1-9 each on its own line.<\/p>\n<p>What I expect to happen:<br \/>\nFor all the numbers I grep from my file except 2 to be colored.<\/p>\n<p>What actually happens:<br \/>\nNeither when preceding the grep with GREP_OPTIONS when I grep 4, nor when GREP_OPTIONS is exported prior to grepping 5, is the resulting output colored.<\/p>\n<p>What does work:<br \/>\nPassing &#8211;color=always as a genuine grep parameter. Passing (for example) -V in GREP_OPTIONS either on the same line or exported.<\/p>\n<p>Additional notes:<br \/>\nThis crippling might be some kind of a safety measure to prevent all the breakage that doing what I&#8217;m attempting to do risks inflicting on the system. But I&#8217;ve not been able to find any documentation about such a design decision having been made, and in contrast, the man page to my understanding implies that this should, in fact, work.<\/p>\n<p>Steps to reproduce:<\/p>\n<p>jani@saegusa:~$ printenv | grep -i grep<br \/>\njani@saegusa:~$ grep 1 test # colored<br \/>\n1<br \/>\njani@saegusa:~$ grep 2 test | cat # not colored<br \/>\n2<br \/>\njani@saegusa:~$ grep &#8211;color=always 3 test | cat # colored<br \/>\n3<br \/>\njani@saegusa:~$ GREP_OPTIONS=&#8217;&#8211;color=always&#8217; grep 4 test | cat # NOT colored!<br \/>\n4<br \/>\njani@saegusa:~$ export GREP_OPTIONS=&#8217;&#8211;color=always&#8217;<br \/>\njani@saegusa:~$ grep 5 test | cat # NOT colored!<br \/>\n5<br \/>\njani@saegusa:~$ export GREP_OPTIONS=&#8217;-V&#8217;<br \/>\njani@saegusa:~$ grep 6 test | cat # control<br \/>\ngrep (GNU grep) 2.10<br \/>\nCopyright \u00a9 2011 Free Software Foundation, Inc.<br \/>\nLisenssi GPLv3+: GNU GPL versio 3 tai my\u00f6h\u00e4isempi<br \/>\nT\u00e4m\u00e4 on vapaa ohjelma: voit vapaasti muuttaa ja jakaa sit\u00e4 edelleen.<br \/>\nOhjelmalla EI OLE TAKUUTA siin\u00e4 laajuudessa kuin laki sen sallii.<\/p>\n<p>Tekij\u00e4t: Mike Haertel ja muut, katso .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Neither when preceding with GREP_OPTIONS nor when GREP_OPTIONS is exported is the resulting output colored. Passing &#8211;color=always as a genuine grep parameter works, as does passing -V in GREP_OPTIONS.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8860],"tags":[3415],"class_list":["post-2564","post","type-post","status-publish","format-standard","hentry","category-vianhallintajarjestelmat","tag-grep","sijainti-launchpad"],"_links":{"self":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/2564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/comments?post=2564"}],"version-history":[{"count":3,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/2564\/revisions"}],"predecessor-version":[{"id":2567,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/2564\/revisions\/2567"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/media?parent=2564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/categories?post=2564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/tags?post=2564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}