我编写了以下简单的bash脚本来运行我的应用程序:
ARGS="-XX:OnOutOfMemoryError=\"kill -9 %p\""
java $ARGS
当我运行此脚本时,输出如下:
Unrecognized option: -9
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
但是......当我运行时修改脚本如下:
ARGS="-XX:OnOutOfMemoryError=\"kill -9 %p\""
java -XX:OnOutOfMemoryError="kill -9 %p"
输出不同:
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
. . . etc
有什么区别?我以为我跑了同样的命令? bash用双引号做什么?