Debian Bug report logs -
#475772
dpkg should set GREP_OPTIONS
Reported by: Kevin Hunter <hunteke@earlham.edu>
Date: Sat, 12 Apr 2008 20:57:12 UTC
Severity: normal
Done: Osamu Aoki <osamu@debian.org>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded to debian-bugs-dist@lists.debian.org, unknown-package@qa.debian.org:
Bug#475772; Package a lot of them.
(full text, mbox, link).
Acknowledgement sent to Kevin Hunter <hunteke@earlham.edu>:
New Bug report received and forwarded. Copy sent to unknown-package@qa.debian.org.
(full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: a lot of them
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.
Kevin
Information forwarded to debian-bugs-dist@lists.debian.org, unknown-package@qa.debian.org:
Bug#475772; Package a lot of them.
(full text, mbox, link).
Acknowledgement sent to Colin Watson <cjwatson@debian.org>:
Extra info received and forwarded to list. Copy sent to unknown-package@qa.debian.org.
(full text, mbox, link).
Message #10 received at 475772@bugs.debian.org (full text, mbox, reply):
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 [cjwatson@debian.org]
Bug reassigned from package `a lot of them' to `general'.
Request was from Colin Watson <cjwatson@debian.org>
to control@bugs.debian.org.
(Sun, 13 Apr 2008 18:12:04 GMT) (full text, mbox, link).
Information forwarded to debian-bugs-dist@lists.debian.org, <debian-devel@lists.debian.org>:
Bug#475772; Package general.
(full text, mbox, link).
Acknowledgement sent to Kevin Hunter <hunteke@earlham.edu>:
Extra info received and forwarded to list. Copy sent to <debian-devel@lists.debian.org>.
(full text, mbox, link).
Message #17 received at 475772@bugs.debian.org (full text, mbox, reply):
At 2:08p -0400 on Sun, 13 Apr 2008, Colin Watson wrote:
> reassign 475772 general
>> I think an appropriate solution would be to unset or export
>> GREP_OPTIONS='--color=none' in the beginning of scripts that rely on grep.
> [not feasible, *lots* of legacy scripts to fix]
Good point. I guess the mode I was thinking as I wrote that was more
along the lines of "start from a known good point". Fine, it won't
happen overnight, but it could be entered into a "best practices" thing
for noob maintainers and whatnot.
For a semi-analogous example, I'm seeing more and more folks build their
website CSS by starting with a block of rules and selectors that resets
all CSS to be the same across all browsers. I think this is very good
practice. For reference:
http://snipurl.com/24bfp [snipplr_com]
I'm not saying fix all packages, but perhaps enter the general mindset
and let it trickle down.
> [fix your *interactive* environment]
> alias grep='grep --color=always'
Now see, that's smart! This fixes the *interactive* environment, and
leaves scripts to do their own thing. Nice. A little tidbit here, a
bit more there, and sooner or later I'll get my environment perfect.
/me edits his .bashrc
Thanks!
Kevin
Reply sent to Osamu Aoki <osamu@debian.org>:
You have taken responsibility.
(full text, mbox, link).
Notification sent to Kevin Hunter <hunteke@earlham.edu>:
Bug acknowledged by developer.
(full text, mbox, link).
Message #22 received at 475772-done@bugs.debian.org (full text, mbox, reply):
Hi,
(I do not understand why the submitter does not use
GREP_OPTIONS='--color=auto'.)
Anyway, you can break many normal program operations if you set
unreasonable value to environment variables. This is not just
GREP_OPTION for grep but you can have fun with TAPE or TAR_OPTIONS for
tar. It is only yourself to blame.
Since submitter said "smart" to other fix method, it is best to close
this bug.
Cheers,
Osamu
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Sun, 25 May 2008 07:37:35 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Sun Jul 2 09:16:21 2023;
Machine Name:
bembo
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.