> On Mon, Dec 17, 2012 at 01:44:43PM -0600, Peter Samuelson wrote:
> > [Stefan Sperling]
> > > We could use iatty() to enable --non-interactive if output is not
> > > going to a terminal, for instance.
> > 
> > I floated this idea some time ago and I'm still in favor of it.  But I
> > think a simple isatty(STDERR_FILENO) would be wrong.

[Stefan Sperling]
> Why? Not all ttys are interactive of course. But I don't really care if
> people piping their line printers or modems into svn's stdin get interactive
> mode by default. Is there any other downside to using isatty()?
> 
> And, actually, don't we want to check stdin, not stderr or stdout?

I wasn't objecting to isatty(), but to the idea that
isatty(STDERR_FILENO) would be sufficient.  As you say, stdin is more
appropriate than stderr.  But you _can_ have a situation where you are
on a tty but stdin is not.  For example:

    # revert part of an import of a dirty working tree
    find . -name '*.obj' | xargs svn rm

(Perhaps 'svn rm' will not cause interactive prompting - for now - but
I hope you get the idea.)

Of course, so long as interactive prompts use stdin, isatty(STDIN_FILENO)
makes sense.  But this sort of usage is why I think prompting should
instead use /dev/tty, for both input and output.  And then if /dev/tty
cannot be opened, assume --non-interactive.

Peter

Reply via email to