Stefan Sperling wrote on Mon, Dec 17, 2012 at 21:39:49 +0100:
> 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.
>
> 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?
>
> > What you want is
> > to detect that there is a controlling terminal at all - something like:
> >
> > #if WINDOWS
> > #define CON "CON:"
> > #else
> > #define CON "/dev/tty"
> > #endif
> > fd = open(CON, O_RDWR);
> > if (fd >= 0) {
> > close(fd);
> > ...
> > }
> >
> > (Of course I have no idea if "CON:" behaves that way. But there must
> > be _some_ way to determine, on Windows, whether you have a terminal
> > window available.)
>
> The simple patch below implements it with the isatty() on *nix and
> _isatty() on Windows (untested -- thanks for the hint Bert!).
>
> We can still change this implementation to use your open() /dev/tty idea later.
>
> However, this is enough to suppress prompts if stdin is piped into 'svn'
> and if 'svn' is run from cron. I believe that's an improvement.
>
> > Someone - was it Mark, perhaps? - objected to this idea on the basis
> > that some wrapper programs out there may try to "scrape" the prompts,
> > in interactive mode, and supply the correct input from, e.g., GUI
> > dialog boxes.
>
> Well, I would guess there are more people who are bitten by forgetting
> to pass --non-interactive in normal scripts than there are people writing
> scrapers that type answers into the prompts. I've met one person who
> made this mistake just last week, who couldn't figure out why 'svn' was
> hanging up their automated build jobs (it was asking for credentials).
Was the automated build job not running svn with an empty (or closed) stdin?
Received on 2012-12-18 01:01:07 CET