summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-05-30 21:32:02 +0000
committerbapt <bapt@FreeBSD.org>2015-05-30 21:32:02 +0000
commit051d0fa6db86e5a836a192ba3224ebf75427461b (patch)
tree6e873d2f057c7a66fe19f6178dab4971860a6984 /usr.sbin
parentb5d16437e1538b1b2c6f842b6fdd5a285227ed8d (diff)
downloadFreeBSD-src-051d0fa6db86e5a836a192ba3224ebf75427461b.zip
FreeBSD-src-051d0fa6db86e5a836a192ba3224ebf75427461b.tar.gz
MFC: r259773, r259774, r259775
Do not print a question in non-interractive mode but explain why boostrapping has failed and how to allow it to happen Reported by: jmmv
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg/pkg.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index d05d544..90a215d 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -819,6 +819,11 @@ static const char confirmation_message[] =
"The package management tool is not yet installed on your system.\n"
"Do you want to fetch and install it now? [y/N]: ";
+static const char non_interactive_message[] =
+"The package management tool is not yet installed on your system.\n"
+"Please set ASSUME_ALWAYS_YES=yes environment variable to be able to bootstrap "
+"in non-interactive (stdin not being a tty)\n";
+
static int
pkg_query_yes_no(void)
{
@@ -937,10 +942,12 @@ main(int argc, char *argv[])
*/
config_bool(ASSUME_ALWAYS_YES, &yes);
if (!yes) {
- printf("%s", confirmation_message);
- if (!isatty(fileno(stdin)))
+ if (!isatty(fileno(stdin))) {
+ fprintf(stderr, non_interactive_message);
exit(EXIT_FAILURE);
+ }
+ printf("%s", confirmation_message);
if (pkg_query_yes_no() == 0)
exit(EXIT_FAILURE);
}
OpenPOWER on IntegriCloud