The "loop and a half"

Grant Edwards grant.b.edwards at gmail.com
Sat Oct 7 12:52:11 EDT 2017


On 2017-10-07, Steve D'Aprano <steve+python at pearwood.info> wrote:

> sort *could* detect when it is reading from stdin interactively and give an
> introductory message.

There are some command-line utilities that try to do that: they modify
their behavior when they think that stdin or stdout is connected to a
"terminal" instead of a pipe.  Personally, I find that annoying and
inconvenient.  I hate it when I run a program, look at the output and
decide I want to do some processing on it, so I hit 'ctrl-P' and pipe
the output to sed, grep, awk, sort, whatever.

And it doesn't work.


After wasting _way_ too much time trying to figure out what I did
wrong in my sed/grep/awk/whatever command, I finally realize that the
@#$!% program changes its output format when stdout is a pipe, and the
rest of the pipeline was designed to process the stdout-is-a-terminal
output format.

And don't get me started on command-line utilities that use colored
output that's only usable if yor terminal is configured with a black
background. Hint to gentoo portage authors: yellow-on-white text is
_not_ readable.

-- 
Grant









More information about the Python-list mailing list