Hacker News new | ask | show | jobs
by pama 488 days ago
Could this be abstracted enough with the right macros to make a subset of useful lisp commands play well with the shell? It could be a powerful way to extend the shell for interactive use.
1 comments

Yes, that's definitely feasible.

I am currently working on it, the macro will be named (shell-expr) and replace the current experimental (shell-test)

[UPDATE] (shell-expr) is ready and kicking :)

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))))