Introduction
Introduction Statistics Contact Development Disclaimer Help
2ff: Make it idempotent and clean it up a bit - farbfeld - suckless image forma…
git clone git://git.suckless.org/farbfeld
Log
Files
Refs
README
LICENSE
---
commit 728997ff9662e6790165fd76296bef9ff8a09d93
parent 1f8903d1689e5f796fbe227587081d28f864cb07
Author: FRIGN <[email protected]>
Date: Mon, 19 Sep 2016 19:07:27 +0200
2ff: Make it idempotent and clean it up a bit
If a file begins with "farbfeld", we just pass it through.
Diffstat:
M 2ff | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/2ff b/2ff
@@ -5,20 +5,32 @@ if [ "$#" -ne 0 ]; then
fi
TMP=$(mktemp)
-cat > "$TMP";
+cat > "$TMP"
-FORMAT=$(file -ib "$TMP" | cut -d ";" -f 1);
+if [ "$(head -c 8 "$TMP")" = "farbfeld" ]; then
+ cat < "$TMP"
+ exit 0
+fi
+
+FORMAT=$(file -ib "$TMP" | cut -d ";" -f 1)
case "$FORMAT" in
- image/png) png2ff < "$TMP"; ret=$? ;;
- image/jpeg) jpg2ff < "$TMP"; ret=$? ;;
- *) convert "$TMP" png:- 2>/dev/null | png2ff 2>/dev/null; ret=$? ;;
+image/png)
+ png2ff < "$TMP"
+ ;;
+image/jpeg)
+ jpg2ff < "$TMP"
+ ;;
+*)
+ convert "$TMP" png:- 2>/dev/null | png2ff 2>/dev/null
+ ;;
esac
-rm "$TMP";
+ret=$?
+rm "$TMP"
if [ $ret -ne 0 ]; then
- printf "%s: failed to convert %s\n" "$0" "$FORMAT" >&2;
+ printf "%s: failed to convert from %s\n" "$0" "$FORMAT" >&2
fi
-exit $ret;
+exit $ret
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.