bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#573704: gettext: msgunfmt colorizes if stdout is terminal, but d


From: Bruno Haible
Subject: Re: Bug#573704: gettext: msgunfmt colorizes if stdout is terminal, but does not recognize --color (fwd)
Date: Sat, 13 Mar 2010 15:09:52 +0100
User-agent: KMail/1.9.9

Hi,

Kalle Olavi Niemitalo wrote:
> % msgunfmt /usr/share/locale/fi/LC_MESSAGES/gnome-session-2.0.mo
> 
> then msgunfmt makes msgids purple and msgstrs blue, by adding
> escape sequences like "\033[34m" to the output.  However, if I
> pipe the output to less, like so:
> 
> % msgunfmt /usr/share/locale/fi/LC_MESSAGES/gnome-session-2.0.mo |
>   less -R
> 
> then I do not get any colors.  Apparently, msgunfmt detects that
> stdout is not a terminal.

Yes, when the output goes to a file, the user normally does not want
escape characters in it.

> Such detection is all right but there 
> should be a way to enable colors regardless.  In ls and git, this
> is done with a --color option, but msgunfmt does not support that:
> 
> % LANG=C msgunfmt --color 
> /usr/share/locale/fi/LC_MESSAGES/gnome-session-2.0.mo
> msgunfmt: unrecognized option '--color'
> Try `msgunfmt --help' for more information.
> 
> I can instead get the desired result by filtering the output
> through msgcat:
> 
> % msgunfmt /usr/share/locale/fi/LC_MESSAGES/gnome-session-2.0.mo |
>   msgcat --color - |
>   less -R
> 
> but it seems silly that msgunfmt cannot do this on its own, given
> that it already supports colorizing the output to a terminal.

Indeed. It is documented that "msgcat --color" can do the colorizing.
But you are right with your expectation.

I've implemented your suggestion:
  
http://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=5d205628d5822bb9ebfaf7eb6ab0aaaeff63848c

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]