summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/Interactive.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-02-21 19:18:26 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-02-21 19:18:26 +0000
commitd41b9a37a8b1d85851f7a4f2d84911a91d408ac3 (patch)
tree967c95fd7b8b8f2c6728092186a6fc4dba77f1dc /usr.sbin/pkg_add/OpenBSD/Interactive.pm
parent6956293c2bb8a5279b8496991a00b9c43ab8becb (diff)
add optional 3rd choice [y/N/a] for always, so that this question type
will always match.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/Interactive.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Interactive.pm16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Interactive.pm b/usr.sbin/pkg_add/OpenBSD/Interactive.pm
index 95f0a387c97..bbd7ee200d7 100644
--- a/usr.sbin/pkg_add/OpenBSD/Interactive.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Interactive.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Interactive.pm,v 1.1 2005/09/04 22:47:56 espie Exp $
+# $OpenBSD: Interactive.pm,v 1.2 2006/02/21 19:18:25 espie Exp $
#
# Copyright (c) 2005 Marc Espie <espie@openbsd.org>
#
@@ -54,14 +54,20 @@ LOOP:
}
}
+my $always = {};
+
sub confirm
{
- my ($prompt, $interactive, $default) = @_;
+ my ($prompt, $interactive, $default, $key) = @_;
if (!$interactive || !-t STDIN) {
return 0;
}
+ if (defined $key && $always->{$key}) {
+ return 1;
+ }
LOOP2:
- print STDERR $prompt, $default ? '? [Y/n] ' : '? [y/N] ';
+ my $a = defined $key ? '/a' : '';
+ print STDERR $prompt, $default ? "? [Y/n$a] " : "? [y/N$a] ";
my $result = <STDIN>;
chomp $result;
@@ -73,6 +79,10 @@ LOOP2:
if ($result eq 'no' or $result eq 'n') {
return 0;
}
+ if (defined $key && $result eq 'a') {
+ $always->{$key} = 1;
+ return 1;
+ }
if ($result eq '') {
return $default;
}