File: imgsize-exit-code.patch

package info (click to toggle)
libimage-size-perl 3.221-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 508 kB
  • ctags: 23
  • sloc: xml: 816; perl: 550; makefile: 4
file content (65 lines) | stat: -rw-r--r-- 1,433 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Description: exit with status code 0 on failure
Author: Christoph Berg <myon@debian.org>
Reviewed-by: Jonathan Yu <jawnsy@cpan.org>
Origin: vendor
Forwarded: no
--- a/imgsize
+++ b/imgsize
@@ -46,11 +46,13 @@
 $opts{f} &&
     ($rtn = \&return_fmt);
 
+my $error = 0;
+
 if (@ARGV > 1)
 {
     foreach (@ARGV)
     {
-        printf "$_: %s\n", $rtn->($_);
+        print STDOUT sprintf("%s: %s\n", $_, $rtn->($_));
     }
 }
 else
@@ -58,7 +60,14 @@
     printf "%s\n", $rtn->($ARGV[0]);
 }
 
-exit 0;
+exit $error;
+
+sub return_html
+{
+    my ($html) = html_imgsize($_[0]);
+
+    (defined $html) ? $html : ("error", $error = 1);
+}
 
 sub return_attr
 {
@@ -67,7 +76,7 @@
     my ($width, $height, $err) = imgsize($file);
 
     return (defined $width) ?
-        "(-width => $width, -height => $height)" : "error: $err";
+        "(-width => $width, -height => $height)" : ("error: $err", $error = 1);
 }
 
 sub return_imgsize
@@ -76,7 +85,7 @@
 
     my ($width, $height, $err) = imgsize($file);
 
-    return (defined $width) ? "$width $height" : "error: $err";
+    return (defined $width) ? "$width $height" : ("error: $err", $error = 1);
 }
 
 sub return_fmt
@@ -86,7 +95,7 @@
     my ($width, $height, $err) = imgsize($file);
 
     return (defined $width) ?
-        sprintf($opts{f}, $width, $height, $err) : "error: $err";
+        sprintf($opts{f}, $width, $height, $err) : ("error: $err", $error = 1);
 }
 
 __END__