if [ -z "$OPTION" ] # if option is not given(empty) then:
then
command1 --defaultOption
else
command1 $OPTION
fi \
2> >( function1 "$DETAILS" ) \
< <( command2 "$OTHER_DETAILS" )
I am seriosly puzzled how directing stderr to a file and feeding a file into stdin interact with an if statement.
Well known things are:
2>filename# Redirect stderr to file "filename."
2>>filename# Redirect and append stderr to file "filename."
command < input-file > output-file
< input-file command > output-file
My guess would be:
command2 generates a file which is forwarded either to command1's stdin with --defaultOption (if $OPTION is empty, then case) or to command1's stdin with $OPTION (if $OPTION is not empty, else case). stderr of command1 is redirected to function1 (which as an example might be some sort of progress-bar display).
So my questions are:
Are the whitespaces between the brackets < < and > > necessary? Is it actual an append (whitespace ignored), or a "double" redirect?
Am I missing an interaction between brackets and braces >( and <(?
Does it somehow influence the evaluation of the the if? Or is only -z $OPTIONtested?
Can I understand what's going on better if I write the outputted file of command2 to the disk, then check for the option and read it again in the if statement?
command2 "$OTHER_DETAILS" --out=file.txt
if [ -z "$OPTION]
then
command1 --defaultOption --in=file.txt 2>function1
else
command1 "$OPTION" --in=file.txt 2>function1
fi
This is part of a script I found over there: http://linuxtv.org/wiki/index.php/V4L_capturing/script (lines 912 through 924)