2

在 shell 脚本中,以下是什么意思?

OVERRIDE="-Dplan.override $2"

我们是否将程序的第二个参数的值分配给OVERRIDE变量并创建一个plan.override值为 的新环境变量OVERRIDE

4

1 回答 1

0

You are creating a new variable OVERRIDE with the content -Dplan.override $2 - $2 stands for the second argument your shell script was given. The variable is only usable within your shell script, not outside of it.

Example:

$ ./your-script.sh firstarg secarg
 -> OVERRIDE will have the value -Dplan.override secarg

If you want to make OVERRIDE global, use export in your script:

export OVERRIDE="-Dplan.override $2"

Then source your script from your shell, like

$ source your-script.sh firstarg secarg

Then your variable OVERRIDE is globally available:

$ echo $OVERRIDE
-Dplan.override secarg
于 2012-10-09T11:18:46.440 回答