This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Opening new cygwin window with arguments


On 2012-01-17, Jon Hughes wrote:
> Gary Johnson <garyjohn <at> spocom.com> writes:
> > 
> > I'm afraid I don't understand the problem.  Color _is_ enabled in
> > the new terminal.
> > 
> > As an experiment/demonstration, I executed this command in my home
> > directory which happened to contain a text file, ls.out, in which
> > the word "out" appeared on a few lines.
> > 
> >     mintty -h a grep --color=always out ls.out
> > 
> > The word "out" was colored in the new terminal just as I would
> > expect it to be.
> > 
> > What command are you executing that has colored output when executed
> > at the command line but not when executed as an argument to mintty?
> > 
> > Regards,
> > Gary
> > 
> > 
> 
> 
> This is the command I'm using:
> tail -f /foo/test.log | perl -pe 's/error/\e[1;31;43m$&\e[0m/g'
> 
> When I do the following there is no color:
> mintty -h a tail -f /foo/test.log | grep --color=always error
> 
> Your command does work correctly (to color based on a grep command parent, 
> rather than chained) but I'm not sure how to correctly modify it to use tail 
> while still coloring the errors.

The problem is that the shell parses that line as "execute mintty
and pipe its standard output to grep".  The standard output of tail
is not being filtered and perl is not being fed anything.

One way to solve that is to write your command like this:

    mintty sh -c "tail -f /foo/test.log | perl -pe 's/error/\e[1;31;43m$&\e[0m/g'"

HTH,
Gary


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]