> echo "command with ampersand&"> file
>
> Anyway, eval will do what you want; you don't need to source a file.
The quoting behavior for file descriptors used with redirection
operators is specified by POSIX, and is not the problem here as the
shell does behave as specified.
So no, there is no way for me to execute
exec $fd_no>>"fifo_file_$no"
and expect to get "fifo_file_$no" opened as file descriptor $fd_no.
Under all circumstances and any quoting, the shell will just try to exec
the $fd_no command, and will try to redirect the standard output for it.
This is why I am trying to first compose the string "exec
$fd_no>>fifo_file_$no", and then to source that string. But to source it
I need a file with the string. An attempt to just eval the string
(instead of sourcing it) will keep the redirection only for the duration
of the eval statement, and then at the next statement I no longer have
the file descriptor opened.
So as a file containing my string, to be source'd, I would like to use a
fifo. Lets call it "sh_script_fifo", and lets suppose I want to use `ls
-l` as the only line to be written/read on the fifo.
An attempt to write to a fifo that is not already open for reading by
some other (or even the same) process will block the write until such a
time that someone opens the same fifo for reading.
In a similar fashion, an attempt to read a fifo that is not already open
for writing by some other (or even the same) process will block the read
operation until such a time that someone opens the same fifo for writing.
Now I want to both read and write the fifo from the same script, which
means that whatever I try first is going to block my script.
This is why the first operation, write, with `echo ls -l
>./sh_script_fifo &` is terminated by the ampersand and put in the
background. This command will have to wait a little more for me to also
read from the pipe, until the `echo´ can write anything to the pipe.
I would expect this to happen really soon, as my next command is
source ./sh_script_fifo
which opens the fifo for reading and reads it.
However, something is wrong because nothing happens and nothing is read
from the fifo by the `source´ command, it just exits as if the fifo has
been closed immediately after open, with no data ever written.
Timothy Madden