From: Jeff King Date: Mon, 06 Aug 2012 19:45:11 GMT Subject: Re: [PATCH v3 1/2] add interface for /dev/tty interaction 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: > Tay Ray Chuan 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 > > --- > > This is not your fault but seeing term_t made me go "eek, yuck". Agreed. > 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