Reproduction steps
Call get_reply() with no default specified. Enter a bad/ invalid input. Then at the invalid selection" prompt, just hit enter:
Invalid selection, please try again:
Use of uninitialized value $answer in split at UI.pm line nnn.
Fix
This issue can be easily fixed by checking to see if $answer is undefined after it is assigned $default in _tt_readline().
Adding:
### If no default specified, then we could end up with an undefined value
if (!defined $answer){
### Set to empty string to avoid split error later
$answer = "";
}
to
### pose the question
my $answer = defined $preput
? $term->readline($prompt, $preput)
: $term->readline($prompt);
$answer = $default unless length $answer;
like so
### pose the question
my $answer = defined $preput
? $term->readline($prompt, $preput)
: $term->readline($prompt);
$answer = $default unless length $answer;
### If no default specified, then we could end up with an undefined value
if (!defined $answer){
### Set to empty string to avoid split error later
$answer = "";
}
Reproduction steps
Call
get_reply()with no default specified. Enter a bad/ invalid input. Then at the invalid selection" prompt, just hit enter:Fix
This issue can be easily fixed by checking to see if
$answerisundefinedafter it is assigned$defaultin_tt_readline().Adding:
to
like so