9

I would like to write a shell script to start a lein repl and then provide some commands while still keeping the repl running.

For example I might want to do the equivalent of:

lein repl
(dev)
(setup)

I can pipe to the repl by echo "(dev)\n(setup)" | lein repl but the repl terminates afterwards.

Is there a way to get around this or another means of starting a repl and issuing commands from a shell script?

4

1 回答 1

11
(echo "(println :hello)"; cat <&0) | lein repl

这会打印命令——让 REPL 处理它——然后“切换回”到标准输入以进行输入。不过,您可能不得不cat在离开 REPL 后中断通话。

于 2013-10-30T13:35:23.563 回答