Commits

Palmer, 2E0EOL committed eb57f08

Use EXIT_SUCCESS only when there are no differences.

Comments (0)

Files changed (1)

 	my %Opts = ( );
 	my @Params = ( );
 	my $endArgs = 0;
+	my $diffOut = '';
 	foreach my $arg ( @ARGV ) {
 		if ( !$endArgs && $arg eq '--' ) {
 			$endArgs = 1;
 	}
 	getopts('u', \%Opts);
 	eval {
-		Diff(
+		$diffOut = Diff(
 			FileA => $Params[0],
 			FileB => $Params[1],
 			Unified => $Opts{'u'}
 		printf(STDERR "ERROR: %s\n", $@);
 		return EXIT_FAILURE();
 	}
-	return EXIT_SUCCESS();
+
+	if ( $diffOut ) { # Differences?
+		print $diffOut; # Show it
+		return EXIT_FAILURE(); # Need to fail so caller picks it up
+	}
+	return EXIT_SUCCESS(); # Silent success, no differences.
 }
 #----------------------------------------------------------------------------
 sub Diff(@)
 	die(sprintf("Error opening \'%s\' - %s\n", $failName, $!))
 		if ( $failName );
 
-	# Now let's do tje comparison.
+	# Now let's do the comparison.
 	my $diff = diff $Params{FileA}, $Params{FileB}, { STYLE => $style };
-	print $diff;
+	return $diff;
 }
 #----------------------------------------------------------------------------
 exit(Main());