Skip to content

Commit 7741552

Browse files
jxlin123cg505
authored andcommitted
Tweaked raster-filter if statements
I've changed all if statements to use the if [ condition ] style, and removed the check that "$error" is not empty before sending an email, since having convert fail implies an error message, which should be emailed out. (Even with no error message, an email can still be sent, indicating an error with the conversion.) Note that I've also removed the -e option when setting Bash script options, which allows me to better check the error status of convert.
1 parent 56bd453 commit 7741552

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

modules/ocf/files/packages/cups/raster-filter

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# A Tea4CUPS filter to perform rasterization.
44
# Based off the pdf-open script
55

6-
set -euo pipefail
6+
set -uo pipefail
77

88
input=$(mktemp --suffix='.pdf')
99

@@ -22,10 +22,11 @@ fi
2222
output=$(mktemp --suffix='.pdf')
2323
error=$(mktemp)
2424

25-
if ! convert -density 250 "$input" "$output" 2> "$error"; then
26-
if [ -s "$error" ]; then
27-
cat "$error" | "/usr/local/bin/convert_failure"
28-
fi
25+
convert -density 250 "$input" "$output" 2> "$error"
26+
27+
# Check exit status of convert
28+
if [ "$?" -ne 0 ]; then
29+
cat "$error" | "/usr/local/bin/convert_failure"
2930
cat "$input"
3031
exit
3132
fi

0 commit comments

Comments
 (0)