<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>189257</bug_id>
          
          <creation_ts>2007-08-17 17:05 0000</creation_ts>
          <short_desc>revdep-rebuild silently fails if GREP_OPTIONS is set</short_desc>
          <delta_ts>2008-02-21 01:52:05 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Portage Development</product>
          <component>Tools</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <keywords>InSVN</keywords>
          <priority>P2</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>170220</blocked>
          
          <everconfirmed>1</everconfirmed>
          <reporter>matteo.sasso@gmail.com</reporter>
          <assigned_to>tools-portage@gentoo.org</assigned_to>
          <cc>david.bonnafous@math.ups-tlse.fr</cc>

      

      
          <long_desc isprivate="0">
            <who>matteo.sasso@gmail.com</who>
            <bug_when>2007-08-17 17:05:16 0000</bug_when>
            <thetext>Using environment variables to personalize the output of common utilities, like grep and du, often breaks clueless scripts.

My GREP_OPTIONS is set to &quot;--color=auto --directories=recurse -E&quot; and this causes problems with revdep-rebuild: it correctly finds many broken binaries (and their packages) but it later quits, saying there&apos;s nothing to do (e.g. &quot;There are no dynamic links to libexpat.so.0... All done.&quot;).

I&apos;m posting a trivial patch that fixes the problem.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>matteo.sasso@gmail.com</who>
            <bug_when>2007-08-17 17:11:04 0000</bug_when>
            <thetext>Created an attachment (id=128415)
Proposed patch

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>arfrever@gentoo.org</who>
            <bug_when>2007-08-17 21:51:18 0000</bug_when>
            <thetext>Maybe:
unset GREP_OPTIONS</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>matteo.sasso@gmail.com</who>
            <bug_when>2007-08-17 22:18:20 0000</bug_when>
            <thetext>Yep, that&apos;s cleaner.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>matteo.sasso@gmail.com</who>
            <bug_when>2007-08-18 14:16:05 0000</bug_when>
            <thetext>Created an attachment (id=128481)
Proposed patch v2

Cleaner line by Arfrever.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>michael@smith-li.com</who>
            <bug_when>2007-08-23 19:55:01 0000</bug_when>
            <thetext>I don&apos;t think this is a valid fix. If users want to break revdep-rebuild by setting unusual environment variables, there&apos;s nothing we can do to stop it. We could start wrapping coreutils like this:
grep() { /bin/env - /bin/grep &quot;$@&quot;; }, but even after we do that for every tool, someone will find another way to break it. GREP_OPTIONS isn&apos;t the only environment variable that can be set to affect GNU utilities.

In my opinion it would just be a good idea to have a sane environment before running bash scripts.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>matteo.sasso@gmail.com</who>
            <bug_when>2007-08-23 23:59:29 0000</bug_when>
            <thetext>Hi Michael,
I wanted to point out that this fix wasn&apos;t made to prevent users from breaking scripts. After all, if they really want to, they can modify the scripts themselves and see what happens. So this is not about &quot;security&quot; or &quot;perfect robustness&quot;.

My fix just tries to avoid some frustration for those few users that actually read manpages and discover that some well documented environment variables can be used to modify default behavior for some commands. I really don&apos;t know how unusual this is, but I think you will agree that this is not completely unreasonable. Some users don&apos;t understand the subtleties of shell programming and would probably expect scripts to work anyway (maybe protecting themselves somehow). And the problem is: 90% of them will! (They either don&apos;t use grep or they use it in a way that doesn&apos;t involve those specific GREP_OPTIONS). For this reason, problems could arise a long time after a user made this modification to the environment (and has probably forgotten about it).
Yes, expert users will expect some breakage and be on guard. Unfortunately, not everybody is an expert.

What this fix tries to accomplish is to save developers&apos; time (i.e. people that think revdep-rebuild doesn&apos;t work anymore and file bug reports) and/or some headache of said users. I think it does its job.

I agree with you on the fact that it is not a complete fix: there are many tools that rely on environment variables and make other assuptions. Your solutions would solve the general case in an elegant way. Another solution would be to use &quot;env&quot; to give a clean environment to the shell process that runs the script. Unfortunately that requires to identify all variables that are actually useful for the script (e.g. PATH) and a lot of testing.

Of the many solutions that could solve the general problem, none of them is probably worth the effort. My solution is trivial (doesn&apos;t break anything) and catches a common case. After all, grep is probably one of the most used utilities, especially as far as scripts are concerned.

It&apos;s useful for me and maybe will be for someone else too.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>michael@smith-li.com</who>
            <bug_when>2008-01-22 22:24:19 0000</bug_when>
            <thetext>Created an attachment (id=141615)
revdep-rebuild_r453_unset_GREP_OPTIONS.patch

Patch against r453 in SVN -- I&apos;ve registered my reservations against patching every esoteric GNU extension. Clearing the entire environment isn&apos;t an option either.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>fuzzyray@gentoo.org</who>
            <bug_when>2008-02-18 18:09:58 0000</bug_when>
            <thetext>$ svn commit -m &quot;unset GREP_OPTIONS to prevent problems with grep. (Bug 189257)&quot;
Sending        revdep-rebuild/revdep-rebuild
Transmitting file data .
Committed revision 464.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>fuzzyray@gentoo.org</who>
            <bug_when>2008-02-21 01:52:05 0000</bug_when>
            <thetext>Released in gentoolkit-0.2.4_rc2</thetext>
          </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>128415</attachid>
            <date>2007-08-17 17:11 0000</date>
            <desc>Proposed patch</desc>
            <filename>revdep-rebuild.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIC91c3IvYmluL3JldmRlcC1yZWJ1aWxkCTIwMDctMDQtMDQgMTQ6NDA6MjMuMDAwMDAwMDAw
ICswMjAwCisrKyAvdXNyL2xvY2FsL2Jpbi9yZXZkZXAtcmVidWlsZAkyMDA3LTA4LTE3IDE4OjUw
OjExLjAwMDAwMDAwMCArMDIwMApAQCAtNTQsNiArNTQsOSBAQAogCiBlY2hvICJDb25maWd1cmlu
ZyBzZWFyY2ggZW52aXJvbm1lbnQgZm9yIHJldmRlcC1yZWJ1aWxkIgogCisjIENsZWFyIEdSRVBf
T1BUSU9OUworZXhwb3J0IEdSRVBfT1BUSU9OUz0iIgorCiAjIE9iZXkgUE9SVEFHRV9OSUNFTkVT
UwogUE9SVEFHRV9OSUNFTkVTUz0kKHBvcnRhZ2VxIGVudnZhciBQT1JUQUdFX05JQ0VORVNTKQog
aWYgWyAhIC16ICIkUE9SVEFHRV9OSUNFTkVTUyIgXQo=
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>128481</attachid>
            <date>2007-08-18 14:16 0000</date>
            <desc>Proposed patch v2</desc>
            <filename>revdep-rebuild.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIC91c3IvYmluL3JldmRlcC1yZWJ1aWxkCTIwMDctMDQtMDQgMTQ6NDA6MjMuMDAwMDAwMDAw
ICswMjAwCisrKyAvdXNyL2xvY2FsL2Jpbi9yZXZkZXAtcmVidWlsZAkyMDA3LTA4LTE3IDE4OjUw
OjExLjAwMDAwMDAwMCArMDIwMApAQCAtNTQsNiArNTQsOSBAQAogCiBlY2hvICJDb25maWd1cmlu
ZyBzZWFyY2ggZW52aXJvbm1lbnQgZm9yIHJldmRlcC1yZWJ1aWxkIgogCisjIENsZWFyIEdSRVBf
T1BUSU9OUwordW5zZXQgR1JFUF9PUFRJT05TCisKICMgT2JleSBQT1JUQUdFX05JQ0VORVNTCiBQ
T1JUQUdFX05JQ0VORVNTPSQocG9ydGFnZXEgZW52dmFyIFBPUlRBR0VfTklDRU5FU1MpCiBpZiBb
ICEgLXogIiRQT1JUQUdFX05JQ0VORVNTIiBdCg==
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>141615</attachid>
            <date>2008-01-22 22:24 0000</date>
            <desc>revdep-rebuild_r453_unset_GREP_OPTIONS.patch</desc>
            <filename>revdep-rebuild_r453_unset_GREP_OPTIONS.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIHJldmRlcC1yZWJ1aWxkX3I0NTMJMjAwOC0wMS0yMSAxNDozMDoxOS4wMDAwMDAwMDAgLTA1
MDAKKysrIHJldmRlcC1yZWJ1aWxkCTIwMDgtMDEtMjIgMTc6MjE6NDguMDAwMDAwMDAwIC0wNTAw
CkBAIC0xMyw2ICsxMyw5IEBACiAjIwogIyBHbG9iYWwgVmFyaWFibGVzOgogCisjIE11c3QtYmUt
YmxhbmsgdmFyaWFibGVzOgordW5zZXQgR1JFUF9PUFRJT05TCisKICMgUmVhZG9ubHkgdmFyaWFi
bGVzOgogZGVjbGFyZSAtciBBUFBfTkFNRT0iJHswIyMqL30iICMgVGhlIG5hbWUgb2YgdGhpcyBh
cHBsaWNhdGlvbgogZGVjbGFyZSAtciBPSUZTPSIkSUZTIiAgICAgICAgICMgU2F2ZSB0aGUgSUZT
Cg==
</data>        

          </attachment>
    </bug>

</bugzilla>