Age | Commit message (Collapse) | Author |
|
Else the user might be left wondering what happened. The output from
imagemagick might not be the nicest in the world, but it's bearable for
some given edge-cases.
|
|
The Unix philosophy teaches us that tools should strive to output only
necessary diagnostic information and also reflect errors properly with
the return value.
There were three subtle problems with 2ff:
1) If the farbfeld-passthrough failed, it would return 1 instead
of 1.
2) If the first 8 bytes contained a NUL byte, bash would print
an ugly warning message. Passing it through tr -d '\0' fixes
that.
3) Lack of comments. I added some to make the structure even
clearer, also including using an if-else-structure.
I removed the 2ff error message; the tools themselves print proper
messages already.
|
|
This also frees us from having to store the return value somewhere.
|
|
Thanks Roberto and Evan Gates!
|
|
If a file begins with "farbfeld", we just pass it through.
|
|
I was inspired by the current discussion on dev@ to use shellcheck to
check my scripts and thought it might be a good choice to do this for
the 2ff script.
Not much had to be changed, because I was careful writing it, but still
it won't hurt to but $TMP in double quotes.
|
|
No idea how "xconvert" sneaked into there.
|
|
Thanks izabera for spotting this!
|
|
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).
|
|
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.
|
|
Thanks z3bra for porting this!
Also change 2ff to use case instead of if-blocks.
|
|
This is a wrapper for the different conversion utilities with
filetype detection using file(1) and an imagemagick fallback.
|