summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2005-04-28 22:28:00 +0000
committerderaadt <deraadt@openbsd.org>2005-04-28 22:28:00 +0000
commitc1a66a41bd50e5248ff76d0bda1d53ee4df2c10a (patch)
treeb04e439086085024e737e7a2b89120805c37f002
parentbump major version, just to be sure. (diff)
downloadwireguard-openbsd-c1a66a41bd50e5248ff76d0bda1d53ee4df2c10a.tar.xz
wireguard-openbsd-c1a66a41bd50e5248ff76d0bda1d53ee4df2c10a.zip
if running in -e mode, and stdin is not a tty, then re-print the commands
that are read. This makes this more easily to script. Note: sparc needs a new config(8) installed before attempting to build a new release because of stuff in src/etc/etc.sparc/Makefile.inc
-rw-r--r--usr.sbin/config/main.c7
-rw-r--r--usr.sbin/config/misc.c20
2 files changed, 21 insertions, 6 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 2d2cb808db0..b83116f6a9a 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.36 2004/01/04 18:30:05 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.37 2005/04/28 22:28:00 deraadt Exp $ */
/* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */
/*
@@ -82,6 +82,8 @@ static void optiondelta(void);
int madedir = 0;
+int verbose;
+
void
usage(void)
{
@@ -117,6 +119,8 @@ main(int argc, char *argv[])
case 'e':
eflag = 1;
+ if (!isatty(STDIN_FILENO))
+ verbose = 1;
break;
case 'g':
@@ -153,7 +157,6 @@ main(int argc, char *argv[])
srcdir = optarg;
break;
- case '?':
default:
usage();
}
diff --git a/usr.sbin/config/misc.c b/usr.sbin/config/misc.c
index e638ff41375..a6389b6a3dd 100644
--- a/usr.sbin/config/misc.c
+++ b/usr.sbin/config/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.4 2003/06/28 04:55:07 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.5 2005/04/28 22:28:00 deraadt Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -26,7 +26,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: misc.c,v 1.4 2003/06/28 04:55:07 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: misc.c,v 1.5 2005/04/28 22:28:00 deraadt Exp $";
#endif
#include <sys/types.h>
@@ -38,6 +38,8 @@ static char rcsid[] = "$OpenBSD: misc.c,v 1.4 2003/06/28 04:55:07 deraadt Exp $"
#include "misc.h"
+extern int verbose;
+
int
ask_cmd(cmd_t *cmd)
{
@@ -47,6 +49,8 @@ ask_cmd(cmd_t *cmd)
if (fgets(lbuf, sizeof lbuf, stdin) == NULL)
errx(1, "eof");
lbuf[strlen(lbuf)-1] = '\0';
+ if (verbose)
+ printf("%s\n", lbuf);
/* Parse input */
buf = lbuf;
@@ -69,9 +73,17 @@ ask_yn(const char *str)
fflush(stdout);
first = ch = getchar();
- while (ch != '\n' && ch != EOF)
+ if (verbose) {
+ printf("%c", ch);
+ fflush(stdout);
+ }
+ while (ch != '\n' && ch != EOF) {
ch = getchar();
-
+ if (verbose) {
+ printf("%c\n", ch);
+ fflush(stdout);
+ }
+ }
if (ch == EOF || first == EOF)
errx(1, "eof");