[hackers] [farbfeld] Use stdin and stdout with 2ff || FRIGN

From: <git_AT_suckless.org>
Date: Fri, 11 Dec 2015 14:56:37 +0100 (CET)

commit 1c801ebeaacd92d08b0225dd7e8c8e7963aa59d8
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Fri Dec 11 14:51:02 2015 +0100
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Fri Dec 11 14:56:04 2015 +0100

    Use stdin and stdout with 2ff
    
    It always seemed odd to have a file-argument for 2ff, given all other
    farbfeld conversion tools operate on stdin and stdout only.
    Given I received numerous e-mails on this matter I've decided to change
    the usage to lessen the confusion.
    
    Maybe there's a way to do some magic with tee(1), but I didn't bother
    just yet.
    To ease the transition, the number of arguments are checked and a usage
    printed if arguments are given.

diff --git a/2ff b/2ff
index af4d7b3..2b0cbd9 100755
--- a/2ff
+++ b/2ff
_AT_@ -1,8 +1,18 @@
 #!/bin/sh
-FORMAT=`file -ib "$1" | cut -d ";" -f 1`
+if [ "$#" -ne 0 ]; then
+ echo "usage: $0" >&2
+ exit 1
+fi
+
+TMP=$(mktemp)
+cat > $TMP;
+
+FORMAT=$(file -ib $TMP | cut -d ";" -f 1);
 
 case "$FORMAT" in
- image/png) png2ff < "$1" ;;
- image/jpeg) jpg2ff < "$1" ;;
- *) convert "$1" png:- | png2ff ;;
+ image/png) png2ff < $TMP ;;
+ image/jpeg) jpg2ff < $TMP ;;
+ *) convert $TMP png:- | png2ff ;;
 esac
+
+rm $TMP;
Received on Fri Dec 11 2015 - 14:56:37 CET

This archive was generated by hypermail 2.3.0 : Fri Dec 11 2015 - 15:00:30 CET