Ralph Corderoy <[EMAIL PROTECTED]> writes:
>
> Hi,
>
> ! /* Patch: This routine used to get the terminal file descriptor with
> ! 'fileno (stdout)', but this is wrong when our output is being piped
> ! to a program, as in 'show -form mhl.body | pgpv', causing mhshow to
> ! hang at the prompt below. If stdout isn't a terminal, get the
> ! terminal file descriptor using the special "/dev/tty" pseudonym.
> ! -- Dan Harkless <[EMAIL PROTECTED]>, 1999-04-09 */
> ! if (tty_FILE == NULL) {
> ! if (isatty(STDOUT_FILENO))
> ! tty_FILE = stdout;
> ! else
> ! tty_FILE = fopen("/dev/tty", "r+");
> ! tty_fd = fileno(tty_FILE);
> ! }
>
> Can we get here without having a /dev/tty? Via a cron job perhaps?
> If so, presumably tty_FILE is NULL when passed to fileno()?
Yeah, sorry. I know I should be checking the return value of the fopen()
there. I was planning to do that once I got everything working, but I
wasted so much time trying to hack the code to retain the standout
formatting for the prompt that I eventually had to draw the line and figure
someone else would take a look at this area when they cleaned up all the
code that assumes stdout is a terminal.
I doubt there are many cron jobs out there that call [mh]show, however...
> Should any prompt be given if *stdin* isn't a terminal?
Right now the prompts are just pauses, so eliminating them when stdin isn't
a terminal is reasonable behavior. If the MH 6.8.4 prompting mechanism
(which Kimmo Suominen recently wrote an nmh-1.0 patch for) is adapted,
however, you can imagine someone wanting to do something like:
(echo n; echo n; echo ""; echo q) | show
in a script or alias. If we just turn off the prompts when stdin isn't a
terminal, we'll be disallowing that kind of control.
-----------------------------------------------------------------------
Dan Harkless | To prevent SPAM contamination, please do not post this
[EMAIL PROTECTED] | private email address to the USENET or WWW. Thank you.