Hello Beni, Sorry about the delay in answering this. For some reason, your email came through to my account completely empty.
> Hello and thanks for all the fish ;-). It fits my dreams for the > perfect shell almost exactly. Thank you. Glad to hear it. > One example for powerful orthogonality that I always wanted to have > was to remove the repetition between similar process substitution > commands. This is frequently useful with diff: > > $ diff <(cd DIR1; find -type f -print0 | xargs -0 md5sum) <(cd DIR2; > find -type f -print0 | xargs -0 md5sum) > > "psub" is just a command which prints a filename, solving it neatly (*): Yes, I'm pretty happy about psub as well. > > > diff (for d in DIR1 DIR2; cd $d; find -type f -print0 | xargs -0 md5sum | > > psub; end) > > But what about input substitutions: > > $ foo --log >(sendmail me -) --output >(wput ftp://my -) > > > > While less frequently needed, they are still desirable. One simple > syntax I can think of is (psub <command>): > > > foo --log (psub sendmail me -) --output (psub wput ftp://my -) > > This will more-of-less work because if psub is running the command it > can steal stdout for printing the pipe filename. But then the program > can't output to the terminal - it must be redirected to /dev/null or > something like that. Part of this problem is that pipelines won't > work: > > foo --output (psub sort | sendmail me -) > > This can't work because we want the output of psub. Any ideas? > Devilish thought: perhaps "psub command" should print the pipe name to > stdin? We need to tell the command substitution to use stdin > somehow... There are two critical operations for process substitution of input to work: 1). Output a filename as the only output from the subshell, this can as near as I can tell only be done by the last command of the subshell 2). Redirect stdin to the file pointed to by 1). This can only be done by the first command of the subshell, as near as I can tell. So either one makes psub internally call the other commands, but that means making psub a builtin (or accepting that some forms of parameter expansion will not be performed 100% correctly): foo --log (psub sendmail me -) or one could split the psub implementation into two functions foo --log (psub1|sendmail me -|psub2) I'm not appealed by either one of these, though. Truthfully, I don't really like input process substitution, since it reverses the flow of information - data suddenly flows from the job into the command substitution. Usually, one can simply use a pipeline to do the same thing. In your example above, one would need two pipelines since the foo command has two separate streams of output, meaning that you'd need to manually create named pipes in fish as it is today. It would be a more interesting idea to come up with a readable syntax that allows you to implement this type of forked pipeline, in my opinion. If some form of forked pipe syntax that makes sense is invented, then the rest should fall into place as well. > > (*) An unrelated problem: it only works for absolute dirs. I see no > anolog to bash's "(...)" running code in a sub-process (begin..end is > run in the same shell). How can I change directories temporarily? > It's easy to write a "subshell" command but to be convenient it should > accept pipelines, blocks and loops -- so we need a builtin? I have yet to find a situation that motivates this, but if one exists, I guess a 'subshell' command would be the right way to move ahead. If the uses are rare enough, one can simply use 'fish -c COMMAND'. This means that onbe has to worry about escapes, double evaluation, etc, but it's not that hard, and it already works. > > -- > Beni Cherniavsky <[EMAIL PROTECTED]>, who can only read email on weekends. > Governments are like kernels - everything possible should be done in user > space. Couldn't agree more. -- Axel ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
