tech-userlevel archive

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

Re: the zen of SIGPIPE

I write hackscripts in python. Typically I write them to consume stdin.

import sys

for i in sys.stdin:
        do stuff

type logic.

Now, if I embed this inside a pipe, and kill the input, python warns me 
about incomplete input state, with a verbose backtrace.

If I want to supress it, I can write

import sys
    for i in sys.stdin:
        do stuff

the point is, that in scripting, if you get thrown an error from an early 
termination of a pipe you can code for it. But, when writing command 
sequences, you can't. And like the complainant, I find xargs behaviour 
annoying, because it promotes an error state I don't want to be told 
about into my view.

Given how few programs do it, I too am tempted to say 'gee, maybe this is 
better supressed. Maybe this should be on a -v option. Shame about cat -v 
but ...

or an ENV setting?


Home | Main Index | Thread Index | Old Index