cdiff should detect if there is a terminal
Bug #242115 reported by
Olav Vitters
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
BzrTools |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I'd like to alias diff to cdiff. This so I do not have to remember if I should run cdiff or diff. However, cdiff doesn't automatically disable its colouring when the output goes to a terminal, preventing me from aliasing it.
Basically I want:
bzr diff
to show me the diff in colour, and:
bzr diff > file
not to put the colour escape codes in the file
Suggested solution:
$ cat test.py
#!/usr/bin/python
import sys
print sys.stdout.isatty()
print sys.stdin.isatty()
$ ./test.py
True
True
$ ./test.py > l
$ cat l
False
True
Related branches
lp://qastaging/~benoit.pierre/bzrtools/colordiff_when_tty
- Aaron Bentley: Needs Resubmitting
Changed in bzrtools: | |
status: | New → Fix Released |
To post a comment you must log in.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Olav Vitters wrote:
> Public bug reported:
>
> I'd like to alias diff to cdiff. This so I do not have to remember if I
> should run cdiff or diff. However, cdiff doesn't automatically disable
> its colouring when the output goes to a terminal, preventing me from
> aliasing it.
However, I pipe cdiff through less on occasion, and less is not a
terminal, so that would cause color to be disabled.
Aaron enigmail. mozdev. org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://
iD8DBQFIXoSF0F+ nu1YWqI0RAvGmAJ 9vCV5D8AMYGaRW8 zyt9wxN9Y4dWwCf bbBv EwUG8nYqAW6Os=
ZN94YSVXl/
=waTN
-----END PGP SIGNATURE-----