Skip to content
Browse files

add sanity check for count of arguments (fixes RHBZ #647599)

  • Loading branch information...
1 parent 478560e commit fb60259b93203cb84bbc4b9ef2452be482caef95 @dmaphy committed Feb 26, 2011
Showing with 14 additions and 22 deletions.
  1. +14 −22 pdfmerge
View
36 pdfmerge
@@ -46,7 +46,7 @@ URL: http://dmaphy.github.com/pdfmerge/
END_OF_USAGE
-die $usage if ( $opt_help or $opt_h or ( scalar(@ARGV) == 0 ) );
+die $usage if ( $opt_help or $opt_h or ( scalar(@ARGV) == 0 ) or ( scalar(@ARGV) < 3 ) );
$incantation = << "END_OF_INCANTATION";
@@ -69,29 +69,21 @@ $incantation = << "END_OF_INCANTATION";
END_OF_INCANTATION
-if ( ! scalar(@ARGV) == 0 )
-{
- # $mergedfile gets the output file!
- $mergedfile = pop(@ARGV);
-
- if ( -e $mergedfile )
- {
- print color("red"), "$mergedfile should not exist, it's the name of your output file!\n", color("reset");
- exit 0;
- }
-
-
- # Dealing with merged.ps
+$mergedfile = pop(@ARGV);
- open (FILE, ">merged.ps") || die "can't open merged.ps";
- print FILE $incantation;
-
- foreach $ARGV (@ARGV)
- {
- print FILE "\n_begin_job_\n";
- print FILE "(./$ARGV)run\n";print FILE "_end_job_\n";
- }
+if ( -e $mergedfile )
+{
+ print color("red"), "$mergedfile should not exist, it's the name of your output file!\n", color("reset");
+ exit 0;
+}
+open (FILE, ">merged.ps") || die "can't open merged.ps";
+print FILE $incantation;
+foreach $ARGV (@ARGV)
+{
+ print FILE "\n_begin_job_\n";
+ print FILE "(./$ARGV)run\n";
+ print FILE "_end_job_\n";
}
close(FILE);

0 comments on commit fb60259

Please sign in to comment.
Something went wrong with that request. Please try again.