From bfacf0cd114393bf62bd75c8ceccf5c34054224e Mon Sep 17 00:00:00 2001 From: espie Date: Fri, 24 Jun 2016 14:20:49 +0000 Subject: [PATCH] make use of former changes. If list is higher than display go thru more. --- usr.sbin/pkg_add/OpenBSD/Interactive.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/Interactive.pm b/usr.sbin/pkg_add/OpenBSD/Interactive.pm index 0f8fcfe9e08..b5b7b76e613 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.20 2015/01/30 11:42:55 espie Exp $ +# $OpenBSD: Interactive.pm,v 1.21 2016/06/24 14:20:49 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie # @@ -35,14 +35,24 @@ sub ask_list if ($self->{always}) { return $values[0]; } + my ($fh, $pid); + if ($self->{state}->height <= @values + 1) { + $pid = open($fh, "|-", "more", "-ce"); + } + + $fh //= \*STDERR; - $self->{state}->errsay('#1', $prompt); + $self->{state}->fhsay($fh, '#1', $prompt); my $i = 0; for my $v (@values) { - $self->{state}->errsay("#1\t#2: #3", + $self->{state}->fhsay($fh, "#1\t#2: #3", $i == 0 ? "a" : "", $i, $v); $i++; } + if (defined $pid) { + close($fh); + waitpid $pid, 0; + } LOOP: $self->{state}->errprint("Your choice: "); my $result = ; -- 2.20.1