Commit ba154494 authored by FRIGN's avatar FRIGN

2ff: Check return values and handle errors

Also, in case convert(1) is not in the path, it will just return an
error-message giving the MIME-type of the problematic input data.
The return-value is given properly as well (0 on success, 1 on error).
parent b669c864
......@@ -10,9 +10,15 @@ cat > $TMP;
FORMAT=$(file -ib $TMP | cut -d ";" -f 1);
case "$FORMAT" in
image/png) png2ff < $TMP ;;
image/jpeg) jpg2ff < $TMP ;;
*) convert $TMP png:- | png2ff ;;
image/png) png2ff < $TMP; ret=$? ;;
image/jpeg) jpg2ff < $TMP; ret=$? ;;
*) xconvert $TMP png:- 2&>/dev/null | png2ff 2&>/dev/null; ret=$? ;;
esac
rm $TMP;
if [ $ret -ne 0 ]; then
printf "%s: failed to convert %s\n" "$0" "$FORMAT" 1>&2;
fi
exit $ret;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment