|
|
|
|
|
by cosmos0072
485 days ago
|
|
[REWRITTEN FOR CLARITY] Yes, although the current syntax is cumbersome - I am thinking how to improve it. The first part is easy. If you want to run something like (lisp-expr1-produces-a-string) | grep foo
the current solution is echo (lisp-expr1-produces-a-string) | grep foo
The second part, i.e. feeding a command's output into a Scheme function, is more cumbersome.If you want to run echo (lisp-expr1) | grep foo | (lisp-expr2)
the current solution requires (sh-run/string job), namely: (lisp-expr2-accepts-string-arg
(sh-run/string
{echo (lisp-expr1) | grep foo}))
If instead you have a (lisp-expr2...) that reads from an integer file descriptor passed as argument - not a Scheme I/O port - you can write (lisp-expr2-accepts-integer-file-descriptor
(sh-start/fd-stdout
{echo (lisp-expr1) | grep foo}))
[UPDATE] There is also a function (sh-redirect job redirection-args ...) - it can add arbitrary redirections to a job, including pipes, but it's quite low-level and verbose to use |
|
The functions (sh-fd-stdin) (sh-fd-stdout) and (sh-fd-stderr) return the integer file descriptors that a schemesh builtin should use to perform I/O.
With them, you can do
It should work :)