且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以编写命令来支持多行参数,即其中包含新行,如heredocs?

更新时间:2023-12-04 13:57:40

我怀疑这里的问题是命令行处理程序(使用 jline)过早地将命令行值传递给 sbt.在 Unix 上,您需要转义新行以避免 shell 执行命令,我认为这里也会发生同样的情况.

I suspect the issue here is with the command line handler (using jline) passing command line values to sbt too prematurely. On Unixes you need to escape the new line to avoid the shell to execute a command and I think the same happens here.

我不知道是否有办法避免执行模式并进入多行模式.我也不认为 sbt 提供该功能.

I don't know if there's a way to avoid the execution mode and enter multiline one, though. I also don't think that sbt offers the feature.

经过进一步调查,LineReader 揭示了所有的行处理.我对它在 sbt 中的使用方式的理解告诉我,在输入按键或特殊值之前,无法指示 sbt 继续读取行.

Upon closer investigation, LineReader reveals all the line handling. My understanding of how it's used in sbt tells me that there's no way to instruct sbt to keep reading lines until a keystroke or a special value gets entered.

shell 内部命令执行实例化 FullReader 的工作,然后读取行以便在代码中查看它,该代码是机器实例化的地方.

The shell internal command does the job of instantiating FullReader and then reading lines so to see it in the code that's where the machinery gets instantiated.