Re: [PATCH v3 1/2] add interface for /dev/tty interaction
- From
Jeff King <peff@peff.net>
- Date
- Aug 6, 2012, 19:45 UTC
- Message-ID
- <20120806194511.GB10039@sigill.intra.peff.net>
- In-Reply-To
- <7vsjc12j5o.fsf@alter.siamese.dyndns.org>
On Sun, Aug 05, 2012 at 01:11:47PM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> Tay Ray Chuan <rctay89@gmail.com> writes: > > > Factor out the opening and closing of /dev/tty from > > git_terminal_prompt(), so that callers may first test if a controlling > > terminal is available before proceeding with prompting proper. > > > > When HAVE_DEV_TTY is not defined, terminal_open() falls back to checking > > tty-ness of stdin and stderr, as getpass() uses them both. > > > > Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> > > --- > > This is not your fault but seeing term_t made me go "eek, yuck".
Agreed.
Show 7 quoted lines
> As far as I can see, use of "FILE *" in existing compat/terminal.c > is not buying us anything useful. The stdio calls made on FILE *fh > are only fopen(), fputs(), fflush() and fclose(), and everything > else goes through fileno(fh). > > So perhaps it is a saner approach to fix that function first before > this patch so that it works on file descriptors.
Yeah, I think that is a good path. I think my original use of stdio was mostly because I started by paring down glibc's implementation of getpass. Since we have niceties like write_in_full, I don't think there's any reason not to just skip stdio.
-Peff