X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=caff%2Fcaff;h=866af1919956fc271ddb86dc45418e4089aaef92;hb=19c5ad0c18bc815c0507ae0f83eb33c7798db932;hp=302bf60c8dbcccd10696f39d8a59ced03b81dacd;hpb=7f34e1c8664e595f83414802a730988e4a07953e;p=pgp-tools.git diff --git a/caff/caff b/caff/caff index 302bf60..866af19 100755 --- a/caff/caff +++ b/caff/caff @@ -448,8 +448,9 @@ sub readwrite_gpg($$$$$%) { sub ask($$;$$) { my ($question, $default, $forceyes, $forceno) = @_; my $answer; + my $yn = $default ? '[Y/n]' : '[y/N]'; while (1) { - print $question,' ',($default ? '[Y/n]' : '[y/N]'), ' '; + print $question,' ',$yn, ' '; if ($forceyes && $forceno) { print "$default (from config/command line)\n"; return $default; @@ -464,9 +465,17 @@ sub ask($$;$$) { }; $answer = ; + if (!defined $answer) { + $OUTPUT_AUTOFLUSH = 1; + die "\n\n". + "End of STDIN reached. Are you using xargs? Caff wants to read from STDIN,\n". + "so you can't really use it with xargs. A patch against caff to read from\n". + "the terminal would be apprechiated.\n". + "For now instead of cat keys | xargs caff do caff `cat keys`\n"; + }; chomp $answer; - last if ((defined $answer) && (length $answer <= 1)); - print "grrrrrr.\n"; + last if ((length $answer == 0) || ($answer =~ m/^[yYnN]$/) ); + print "What about $yn is so hard to understand?\nAnswer with either 'n' or 'y' or just press enter for the default.\n"; sleep 1; }; my $result = $default;