by cosmos0072 · 1y ago · 0 comments
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
true (lambda () (lisp-expr-writes-to-fd (sh-fd-stdout))) | grep foo | true (lambda () (lisp-expr-reads-from-fd (sh-fd-stdin)))
It should work :)I am currently working on it, the macro will be named (shell-expr) and replace the current experimental (shell-test)
Now you can write
(import (schemesh all))
(shell-expr (lisp-expression-writing-to-sh-fd-stdout)) | some-shell-command-and-args | (shell-expr (lisp-expression-reading-from-sh-fd-stdin))
An example of such expressions is:
For writing to sh-fd-stdout, (fd-write (sh-fd-stdout) (string->utf8b "hello\n"))
For reading from sh-fd-stdin, (display (utf8b-bytespan->string (fd-read-until-eof (sh-fd-stdin))))