> For years I've wanted a shell command called 'loop' that pipes > the output at the end of the command line back into the input at the > beginning. Maybe I'll put it in toysh. > > (Ok, "for years" turns out to be "for well over a decade": > http://osdir.com/ml/linux.busybox/2004-01/msg00048.html . Sheesh, why > don't people steal my ideas and _implement_ them more often, so I don't > have to?)
I came up with a klunky first draft that takes two arguments: $ ./circle 'echo hi' ./append-something The first argument primes the pump and the second is the one that will run forever. I built it using a fifo: = circle-1 mkfifo /tmp/foo eval $1 >/tmp/foo & eval $2 </tmp/foo |tee x > /tmp/foo The 'tee' is to see that it's running. The '-v' option to also emit the iterations to stdout I implemented with a second fifo: = circle-2 mkfifo /tmp/foo mkfifo /tmp/bar eval $1 >/tmp/foo & eval $2 </tmp/foo |tee /tmp/bar > /tmp/foo & cat /tmp/bar Finally, a test command I tried this with (this is where the loop goes, right?): = append-something while read line do echo "$line a" done Comments appreciated. I'm not clear on the use for this, but it was an interesting exercise. I'm sure there's cleaner ways to do this, especially that second fifo.
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
