
On 2006-05-12, Jeremy Shaw
At Thu, 11 May 2006 23:05:14 +0100, Brian Hulley wrote:
Of course the above could no doubt be improved but surely it is already far easier to understand and much more powerful than the idiosyncratic text based approach used in UNIX shells (including rc).
The idea of representing unix pipes as monads has been around for a while -- but what most people fail to account for is that many (most?) real-world shell scripts also need to deal with return values and stderr. Even standard unix shells are pretty terrible in this regard -- so if we could do it *better* than standard shells -- that could be pretty compelling.
Here are some simple examples of things to handle, starting with failures in a pipeline:
$ aoeu | cat -n ; echo $? bash: aoeu: command not found 0 $
Sweet! A successful return code even though there is clearly a failure. Bash 3.x *finally* added, set -o pipefail -- which would cause the above to return an error. Unfortunately, there is no way to tell which part of the pipeline failed, or any way to attempt recovery of the part that failed.
See also the "pipestatus/PIPESTATUS" arrays in e.g. zsh and ksh. Maybe it's in bash too these days. -- Aaron Denney -><-