inspircd

A modular C++ IRC daemon (ircd). https://www.inspircd.org/
Log | Files | Refs | README

commit a580cacb192ba458b2f643b549ce5b9348eab9d0
parent f1c3833663cec2e4fa7444dbd91556073c94b589
Author: Peter Powell <petpow@saberuk.com>
Date:   Tue, 29 Jan 2019 02:14:09 +0000

Improve the accessibility and robustness of prompt_bool.

- Use "yes" and "no" instead of "y" and "n".
- Validate the true and false responses properly.
- Keep prompting the user for a response until they give one which
  is valid.

Diffstat:
Mmake/console.pm | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/make/console.pm b/make/console.pm @@ -92,8 +92,12 @@ sub print_warning { sub prompt_bool($$$) { my ($interactive, $question, $default) = @_; - my $answer = prompt_string($interactive, $question, $default ? 'y' : 'n'); - return $answer =~ /y/i; + while (1) { + my $answer = prompt_string($interactive, $question, $default ? 'yes' : 'no'); + return 1 if $answer =~ /^y(?:es)?$/i; + return 0 if $answer =~ /^no?$/i; + print_warning "\"$answer\" is not \"yes\" or \"no\". Please try again.\n"; + } } sub prompt_dir($$$;$) {