diff options
author | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-11-12 01:38:44 (EST) |
---|---|---|
committer | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-11-12 01:38:44 (EST) |
commit | f0920f2896c409d519e51744a2e2618a99ec8b8c (patch) | |
tree | 677f64e19d7f2fc4b833411fd44e8014836aba56 /libopkg/user.c | |
parent | 99be91a0fdb86a6826a0cdcf8bede14b7d01c9a8 (diff) |
Don't prompt for user input from stdin if it's not a tty.
Based off a patch by Chris Larson <clarson@mvista.com> for OpenEmbedded.
git-svn-id: http://opkg.googlecode.com/svn/trunk@290 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/user.c')
-rw-r--r-- | libopkg/user.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libopkg/user.c b/libopkg/user.c index 8c960dc..dda5013 100644 --- a/libopkg/user.c +++ b/libopkg/user.c @@ -15,13 +15,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ -#include <stdlib.h> #include <stdio.h> #include <stdarg.h> -#include <string.h> +#include <unistd.h> #include "file_util.h" #include "str_util.h" -#include "user.h" char *get_user_response(const char *format, ...) { @@ -32,6 +30,9 @@ char *get_user_response(const char *format, ...) vprintf(format, ap); va_end(ap); + if (isatty(fileno(stdin))) + return NULL; + response = (char *)file_read_line_alloc(stdin); if (response == NULL) return NULL; |