[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Catching both the exit status and the output
>>>>> peter@robots.ox.ac.uk writes:
Pete> Being able to do
Pete> while <={line >>> var} { echo $var }
Pete> would be brilliant.
Hmm, yes, you could think of it as an assignment operator with a
useful return value. And
cmd >>> var
might really be syntactic sugar for
{ let (x = <={%Background cmd}) { var = $x(2 ...); result $x(1) }}
where %Background is my suggested, generalized primitive. I think I
like this idea.
Pete> Hey whilst we're at it, why not even >>>[n] ?
But now you are beginning to treat it not as an assignment but rather
like a redirection, and users might reasonably expect to be able to
say things like
cmd >>>[1] a >>>[2] b >>>[3] c
and then the shell has to work really hard at reading all those file
descriptors in the right order without blocking either itself or cmd.
Worse, if thinking of this as a redirection you would expect cmd to
execute in the current shell, thus potentially causing the shell to be
writing into a pipeline leading to a process whose output the shell
has to read from a different pipeline. Sounds like a recipe for fatal
blocking to me.
- Harald
PS. Maybe I should add a little disclaimer: I am not a computer
scientist, only a mathematician with more than the usual interest in
computers. So if I am beginning to spout too much nonsense, someone
please stop me. Gently. :-)