fcm icon indicating copy to clipboard operation
fcm copied to clipboard

fcm cm prompting: catch undef STDIN readline result

Open benfitzpatrick opened this issue 10 years ago • 1 comments

We have a chunk of code in lib/FCM/System/CM/Prompt.pm that looks like:

        $answer = readline(STDIN);
        chomp($answer);

This can sometimes cause an error message:

Use of uninitialized value $answer in scalar chomp

This happens when readline returns undef, and one particular case it sets $! to Resource temporarily unavailable.

This looks like a problem with non-blocking vs blocking STDIN handling, and is common to other utilities. We can probably check for defined(answer) and exit with a better message.

benfitzpatrick avatar Dec 04 '14 16:12 benfitzpatrick