如何阻止我的命令行参数在 Maven 插件中被转义?

发布于 2024-08-01 14:14:18 字数 359 浏览 2 评论 0原文

我有一个插件,它使用 Plexus 命令行来调用一些外部进程并捕获输出。 其中一个参数的格式很有趣,带有空格和引号,例如 --range:"25 Aug 2008"-"04 Aug 2009"。 我无法更改参数所需的格式,但 Plexus 会检测参数中的空格并将整个内容用引号引起来。

因此

call --range:"25 Aug 2008"-"04 Aug 2009"

变为

call "--range:"25 Aug 2008"-"04 Aug 2009""

并且调用失败。

我能让 plexus 停止逃避争论吗?

I have a plugin that uses the Plexus Commandline to invoke some external process and capture the output. One of the arguments is in a funny format with spaces and quotes, e.g. --range:"25 Aug 2008"-"04 Aug 2009". I have no way to change the required format of the argument, but Plexus detects the spaces in the argument and wraps the whole thing in quotes.

So

call --range:"25 Aug 2008"-"04 Aug 2009"

becomes

call "--range:"25 Aug 2008"-"04 Aug 2009""

and the invocation fails.

Can I make plexus stop escaping the arguments?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪 2024-08-08 14:14:18

Commandline 对象使用 Shell 与本地环境交互,您可以配置 Shell 来覆盖默认的转义过程,以不转义任何引号:

Commandline cl = new Commandline("call");
commandline.getShell().setQuotedArgumentsEnabled(false);

请注意,这意味着没有参数将被引用,所以请谨慎使用!

The Commandline object uses a Shell to interact with the local environment, you can configure the Shell to override the default escaping process to not escape any quotes:

Commandline cl = new Commandline("call");
commandline.getShell().setQuotedArgumentsEnabled(false);

Be aware that this means that none of the arguments will be enquoted, so use it with care!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文