reassign 475772 general thanks On Sat, Apr 12, 2008 at 04:52:47PM -0400, Kevin Hunter wrote: > I've recently set GREP_OPTIONS='--color=always' in my bashrc. I do this > mainly so that I can see grep's highlighted findings even when viewing > through a pipeline, such as with less. '--color=auto' won't work > because it will turn off the color escapes if it's going down the > pipeline, which is not what I want when I use less. > > This poses a problem for a lot of scripts, which assume that text coming > from their stdin is free from (color) escapes. For instance, I recently > went to install postgresql-client-8.2 in Ubuntu. (I recognize that > Ubuntu != Debian. However, this is also a problem in Etch that I just > didn't report earlier, and I think it could be addressed in both distros.) > > > $ sudo apt-get install postgresql > > ... > >Setting up postgresql-client-8.2 (8.2.7-0ubuntu0.7.10) ... > >update-alternatives: unable to make > >/usr/share/postgresql/8.2/man/man1/dropuser.1.gz.dpkg-tmp a symlink to > >/etc/alternatives/dropuser.1.gz: No such file or directory > > ^^^^^^^^^^^^^^^^^^^^^^^ > > The ^^^^ is color-escaped, which is no good for the symlinking. > > I think an appropriate solution would be to unset or export > GREP_OPTIONS='--color=none' in the beginning of scripts that rely on grep.
It's not clear to me that it's going to be feasible for dpkg to carefully go around and unset every variable that might affect any maintainer script. It could take debuild's approach of removing everything except known-good environment variables, but since it's never done this to date this would probably break quite a few different things; for example I suspect it's probably intentional that you can override the linker with LD_PRELOAD for local testing, and a number of maintainer scripts probably have local environment variable overrides for one thing or another (not necessarily a terribly good idea in official Debian packages, but I can imagine situations where it might be useful). It sounds even less feasible for us to change every single script; there are tens of thousands of the things maintained by at least thousands of different people even just in Debian, and such a job would take years. (sudo does sanitise the environment in some modes of operation, but intentionally not in all.) Would it not involve less in the way of swimming uphill to use a solution that affects only your interactive environment, and that doesn't break scripts? After all, this problem is hardly unique to dpkg or Debian. Try: alias grep='grep --color=always' -- Colin Watson [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]