Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 189257
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Portage Utilities Team <tools-portage@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Matteo Sasso <matteo.sasso@gmail.com>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
revdep-rebuild.patch Proposed patch patch Matteo Sasso 2007-08-17 17:11 0000 374 bytes Details | Diff
revdep-rebuild.patch Proposed patch v2 patch Matteo Sasso 2007-08-18 14:16 0000 370 bytes Details | Diff
revdep-rebuild_r453_unset_GREP_OPTIONS.patch revdep-rebuild_r453_unset_GREP_OPTIONS.patch patch Michael A. Smith 2008-01-22 22:24 0000 343 bytes Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 189257 depends on: Show dependency tree
Bug 189257 blocks: 170220
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2007-08-17 17:05 0000
Using environment variables to personalize the output of common utilities, like
grep and du, often breaks clueless scripts.

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

I'm posting a trivial patch that fixes the problem.

------- Comment #1 From Matteo Sasso 2007-08-17 17:11:04 0000 -------
Created an attachment (id=128415) [details]
Proposed patch

------- Comment #2 From Arfrever Frehtes Taifersar Arahesis 2007-08-17 21:51:18 0000 -------
Maybe:
unset GREP_OPTIONS

------- Comment #3 From Matteo Sasso 2007-08-17 22:18:20 0000 -------
Yep, that's cleaner.

------- Comment #4 From Matteo Sasso 2007-08-18 14:16:05 0000 -------
Created an attachment (id=128481) [details]
Proposed patch v2

Cleaner line by Arfrever.

------- Comment #5 From Michael A. Smith 2007-08-23 19:55:01 0000 -------
I don't think this is a valid fix. If users want to break revdep-rebuild by
setting unusual environment variables, there's nothing we can do to stop it. We
could start wrapping coreutils like this:
grep() { /bin/env - /bin/grep "$@"; }, but even after we do that for every
tool, someone will find another way to break it. GREP_OPTIONS isn'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.

------- Comment #6 From Matteo Sasso 2007-08-23 23:59:29 0000 -------
Hi Michael,
I wanted to point out that this fix wasn'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 "security" or "perfect
robustness".

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't know how
unusual this is, but I think you will agree that this is not completely
unreasonable. Some users don'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't use grep or
they use it in a way that doesn'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' time (i.e. people that
think revdep-rebuild doesn'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 "env" 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'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's useful for me and maybe will be for someone else too.

------- Comment #7 From Michael A. Smith 2008-01-22 22:24:19 0000 -------
Created an attachment (id=141615) [details]
revdep-rebuild_r453_unset_GREP_OPTIONS.patch

Patch against r453 in SVN -- I've registered my reservations against patching
every esoteric GNU extension. Clearing the entire environment isn't an option
either.

------- Comment #8 From Paul Varner 2008-02-18 18:09:58 0000 -------
$ svn commit -m "unset GREP_OPTIONS to prevent problems with grep. (Bug
189257)"
Sending        revdep-rebuild/revdep-rebuild
Transmitting file data .
Committed revision 464.

------- Comment #9 From Paul Varner 2008-02-21 01:52:05 0000 -------
Released in gentoolkit-0.2.4_rc2

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug