andrewchambers / janet-sh

Shorthand shell like functions for janet.
82 stars 6 forks source link

Add support for piping long strings into command #16

Closed autumnull closed 2 years ago

autumnull commented 2 years ago

One really good thing about this module is that it makes it easy to farm out already-implemented tasks to shell commands. There is an issue, though, which is that there is a limit on how long the argument list can be, so if you try to echo a long string to pipe it into another command, it throws an error: spawn failed: "Argument list too long".

I think it would be a great addition to the module to allow piping input into the shell command from a string within janet. Maybe the syntax could be something like this:

(def really-long-string "...")
(sh/$< [stdin really-long-string] | cat)
andrewchambers commented 2 years ago

iirc its already possible like:

(sh/$< cat < "hello")

autumnull commented 2 years ago

you're right that's my bad! that's really helpful, thank you :)