[Pgp-tools-commit] r154 - in trunk: caff debian

Peter Palfrader weasel at costa.debian.org
Thu Jul 28 11:18:56 UTC 2005


Author: weasel
Date: 2005-07-28 11:18:55 +0000 (Thu, 28 Jul 2005)
New Revision: 154

Modified:
   trunk/caff/caff
   trunk/debian/changelog
Log:
Improve diagnosis if caff can't read answers from STDIN

Modified: trunk/caff/caff
===================================================================
--- trunk/caff/caff	2005-07-28 00:23:18 UTC (rev 153)
+++ trunk/caff/caff	2005-07-28 11:18:55 UTC (rev 154)
@@ -448,8 +448,9 @@
 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 @@
 		};
 
 		$answer = <STDIN>;
+		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;

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2005-07-28 00:23:18 UTC (rev 153)
+++ trunk/debian/changelog	2005-07-28 11:18:55 UTC (rev 154)
@@ -15,10 +15,12 @@
      + create unique attachment filenames, thanks Robin H. Johnson
        (Closes: #318469).
      + let caff import keys from file, thanks Jon Åslund (Closes: #318744).
+     + Improve diagnosis if caff can't read answers from STDIN, like
+       when people use xargs  (Closes: #319519).
   * Depend on libtext-template-perl as caff needs it.
   * Update to Standards-Version 3.6.2, no changes necessary.
 
- -- Peter Palfrader <weasel at debian.org>  Wed, 29 Jun 2005 16:36:08 +0200
+ -- Peter Palfrader <weasel at debian.org>  Thu, 28 Jul 2005 13:17:39 +0200
 
 signing-party (0.4.0-1) unstable; urgency=low
 





More information about the Pgp-tools-commit mailing list