Subject: | Non-interactive use of prompt() causes 'Use of uninitialized value' warnings |
An application which is intended to be run interactively was recently
invoked (by accident) non-interactively (from within a shell script).
This resulted in Perl warnings from Term::Prompt. It would be better if
Term::Prompt handled this silently (e.g. only chomping if the input
string is defined).
The behaviour can be repeated with the following code:
$ cat prompt.sh
#!/bin/sh
perl -MTerm::Prompt -e 'prompt("y", "?", "y|n", "")'
$ cat /dev/null |./prompt.sh
Use of uninitialized value in scalar chomp at .../lib/Term/Prompt.pm
line 254.
Use of uninitialized value in substitution (s///) at
.../lib/Term/Prompt.pm line 256.
Use of uninitialized value in substitution (s///) at
.../lib/Term/Prompt.pm line 256.