diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2009-11-28 09:41:15 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2009-11-28 09:41:15 +0000 |
commit | c62b71d3dc2f045434a469d369eff09645474d7c (patch) | |
tree | 07bd909d7f646de9203d76d7c1c6e8a0b5abf8e0 | |
parent | a788d89140485c7e50485df6b911884a581de063 (diff) |
add "always" to ask_list...
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Interactive.pm | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Interactive.pm b/usr.sbin/pkg_add/OpenBSD/Interactive.pm index 85d9e7fd957..b6427542244 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.11 2009/11/17 10:17:21 espie Exp $ +# $OpenBSD: Interactive.pm,v 1.12 2009/11/28 09:41:14 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org> # @@ -19,16 +19,18 @@ use warnings; package OpenBSD::Interactive; +my $always = 0; + sub ask_list { my ($prompt, $interactive, @values) = @_; - if (!$interactive || !-t STDIN) { + if (!$interactive || !-t STDIN || $always) { return $values[0]; } print STDERR $prompt, "\n"; my $i = 0; for my $v (@values) { - printf STDERR "\t%2d: %s\n", $i, $v; + printf STDERR "%s\t%2d: %s\n", $i == 0 ? " a" : "" , $i, $v; $i++; } LOOP: @@ -42,6 +44,10 @@ LOOP: if ($result eq '') { return $values[0]; } + if ($result eq 'a') { + $always = 1; + return $values[0]; + } if ($result =~ m/^\d+$/o) { if ($result >= 0 && $result < @values) { return $values[$result]; @@ -57,8 +63,6 @@ LOOP: } } -my $always = 0; - sub confirm { my ($prompt, $default) = @_; |