summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1994-04-05 14:08:47 +0000
committerjkh <jkh@FreeBSD.org>1994-04-05 14:08:47 +0000
commit68314379f2309f4a2f3b03c227d494a4d43aa7a1 (patch)
treeac02b985aac39d049d15cea2a959286212a9b94f /usr.sbin/pkg_install
parent4549480f2f521e96c7310bbfa8d999677c0dbf9b (diff)
downloadFreeBSD-src-68314379f2309f4a2f3b03c227d494a4d43aa7a1.zip
FreeBSD-src-68314379f2309f4a2f3b03c227d494a4d43aa7a1.tar.gz
Make y_or_n() pay attention to AutoAnswer global.
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/lib/global.c6
-rw-r--r--usr.sbin/pkg_install/lib/lib.h6
-rw-r--r--usr.sbin/pkg_install/lib/msg.c11
3 files changed, 17 insertions, 6 deletions
diff --git a/usr.sbin/pkg_install/lib/global.c b/usr.sbin/pkg_install/lib/global.c
index f5eda0e..d411f5e 100644
--- a/usr.sbin/pkg_install/lib/global.c
+++ b/usr.sbin/pkg_install/lib/global.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id$";
+static const char *rcsid = "$Id: global.c,v 1.1.1.1 1993/08/26 01:19:55 jkh Exp $";
#endif
/*
@@ -25,7 +25,9 @@ static const char *rcsid = "$Id$";
#include "lib.h"
-/* These two are global for all utils */
+/* These are global for all utils */
Boolean Verbose = FALSE;
Boolean Fake = FALSE;
+int AutoAnswer = FALSE;
+
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index f84c31b..4796f85 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -1,4 +1,4 @@
-/* $Id: lib.h,v 1.3 1993/09/05 04:54:21 jkh Exp $ */
+/* $Id: lib.h,v 1.4 1993/09/18 03:39:49 jkh Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -47,6 +47,9 @@
#define FALSE (0)
#endif
+#define YES 2
+#define NO 1
+
/* Usually "rm", but often "echo" during debugging! */
#define REMOVE_CMD "rm"
@@ -145,5 +148,6 @@ int pkg_perform(char **);
/* Externs */
extern Boolean Verbose;
extern Boolean Fake;
+extern int AutoAnswer;
#endif /* _INST_LIB_LIB_H_ */
diff --git a/usr.sbin/pkg_install/lib/msg.c b/usr.sbin/pkg_install/lib/msg.c
index 489fc47..12a2ff0 100644
--- a/usr.sbin/pkg_install/lib/msg.c
+++ b/usr.sbin/pkg_install/lib/msg.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: msg.c,v 1.3 1993/09/04 05:06:50 jkh Exp $";
+static const char *rcsid = "$Id: msg.c,v 1.2 1993/09/03 23:01:15 jkh Exp $";
#endif
/*
@@ -80,14 +80,19 @@ y_or_n(Boolean def, const char *msg, ...)
tty = fopen("/dev/tty", "r");
if (!tty)
barf("Can't open /dev/tty!\n");
- while (ch != 'Y' && ch != 'N') {
+ while (ch != 'Y' && ch != 'N') {
vfprintf(stderr, msg, args);
if (def)
fprintf(stderr, " [yes]? ");
else
fprintf(stderr, " [no]? ");
fflush(stderr);
- ch = toupper(fgetc(tty));
+ if (AutoAnswer) {
+ ch = (AutoAnswer == YES) ? 'Y' : 'N';
+ fprintf(stderr, "%c\n", ch);
+ }
+ else
+ ch = toupper(fgetc(tty));
if (ch == '\n')
ch = (def) ? 'Y' : 'N';
}
OpenPOWER on IntegriCloud