about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-04-25 22:49:52 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-04-25 22:49:52 +0000
commitd30690e8a6d494287d655e1bddd722f5c0bee432 (patch)
tree19a647c867b08a8cf19ad013ba761c6650b72e4f
parent8ae68053f74e825192ebd73a27c40c99fdfd502e (diff)
downloadnetpbm-mirror-d30690e8a6d494287d655e1bddd722f5c0bee432.tar.gz
netpbm-mirror-d30690e8a6d494287d655e1bddd722f5c0bee432.tar.xz
netpbm-mirror-d30690e8a6d494287d655e1bddd722f5c0bee432.zip
exit with proper exit status upon failure
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@894 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rwxr-xr-xgenerator/ppmrainbow20
1 files changed, 14 insertions, 6 deletions
diff --git a/generator/ppmrainbow b/generator/ppmrainbow
index 90a940bf..f98536cd 100755
--- a/generator/ppmrainbow
+++ b/generator/ppmrainbow
@@ -6,6 +6,13 @@ my ($FALSE, $TRUE) = (0,1);
 
 (my $myname = $0) =~ s#\A.*/##;
 
+sub fatal($) {
+    my ($msg) = @_;
+
+    print(STDERR "$msg\n");
+    exit(1);
+}
+
 my ($Twid, $Thgt, $tmpdir, $norepeat, $verbose);
 
 # set defaults
@@ -21,15 +28,16 @@ GetOptions("width=i"   => \$Twid,
            "norepeat!" => \$norepeat,
            "verbose!"  => \$verbose);
 
-die "invalid width and/or height" unless $Twid >= 1 && $Thgt >= 1;
-
+if ($Twid < 1 || $Thgt < 1) {
+    fatal("invalid width and/or height");
+}
 my $verboseCommand = $verbose ? "set -x;" : "";
 
 if (@ARGV < 1) {
-    die("You must specify at least one color as an argument");
+    fatal("You must specify at least one color as an argument");
 } elsif (@ARGV < 2 && $norepeat) {
-    die("With the -norepeat option, you must specify at least two colors " .
-        "as arguments.");
+    fatal("With the -norepeat option, you must specify at least two colors " .
+          "as arguments.");
 }
 
 my @colorlist;
@@ -57,7 +65,7 @@ while (@colorlist >= 2) {
     my $rc = system("$verboseCommand pgmramp -lr $w $Thgt | " .
                     "pgmtoppm \"$colorlist[0]-$colorlist[1]\" >$outfile");
     if ($rc != 0) {
-        die("pgmramp|pgmtoppm failed.");
+        fatal("pgmramp|pgmtoppm failed.");
     }
     $widthRemaining -= $w;
     $n++;