]> diplodocus.org Git - nmh/blob - sbr/read_yes_or_no_if_tty.c
3d7c110427a1efbaea905202c8724f7d11c1d155
[nmh] / sbr / read_yes_or_no_if_tty.c
1 /*
2 * read_yes_or_no_if_tty.c -- get a yes/no answer from the user
3 *
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
7 */
8
9 #include <h/mh.h>
10
11
12 int
13 read_yes_or_no_if_tty (const char *prompt)
14 {
15 static int interactive = -1;
16
17 if (interactive < 0)
18 interactive = isatty (fileno (stdin)) ? 1 : 0;
19
20 return (interactive ? read_switch (prompt, anoyes) : 1);
21 }