本文介绍了preserving说法间距等突入MVN Exec时:JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个shell脚本,启动一个Maven的exec:java程序 -

I have a shell script that launches a Maven exec:java process -

exec mvn exec:java -Dexec.mainClass=... -Dexec.args="$*"

现在可悲的是,如果我跑

Now sadly if I run

./myMagicShellScript arg1 "arg 2"

单串 ARG 2 不让它通过一样,我想一个参数。

the single string arg 2 doesn't make it through as a single argument as I'd like.

有什么想法就如何逃生/通过传递正确的事情(perferably以干净的方式)?

Any thoughts as to how to escape / pass things through properly (perferably in a clean way)?

推荐答案

我接过一看<一个href=\"http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/apache-maven/src/bin/mvn?view=markup\"相对=nofollow> MVN 脚本,并做了一些测试。这是我想出了:

I took a look at the mvn script and did some testing. This is what I came up with:

试着改变你的脚本是这样的:

Try changing your script to look like this:

args=(${@// /\\ })
exec mvn exec:java -Dexec.mainClass=... -Dexec.args="${args[*]}"

这改变了这是每个数组元素中的所有空格用反斜杠转义。

That changes all spaces which are within each array element to be escaped with a backslash.

这篇关于preserving说法间距等突入MVN Exec时:JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 04:42