将变量传递给调用自身的脚本 [英] Passing a Variable to a script calling itself
问题描述
我的脚本正在将ClearCase视图存储在变量中.要在此视图中操作,脚本需要在启动视图后再次在视图内调用自身. 代码看起来像这样
My Script is storing a ClearCase View in a Variable. To operate in this View, the Script needs to call itself inside the View again, after it started the View. The Code looks like this
if($params{ViewSet} eq 'no')
{
# Start the View
# Store the View in $View
# Call the Script in the new-set View with parameter -ViewSet yes
}
if($params{ViewSet} eq 'yes')
{
# Do Work inside the View
}
问题是,显然,当我第二次调用脚本时,变量$View
没有定义,因为它是在第一个if循环中定义的.
The problem is, obviously the Variable $View
is not defined when I call my script the second time, since it is defined in the first if loop.
当我第二次调用脚本时,可以通过存储在$View
中的视图吗?
在输入if-Statement之前先设置View不会字,然后我将两次启动View.
Can I pass the View I stored in $View
when I call the Script the second time?
Setting the View before entering the if-Statements would not word, I would start the View two times then.
推荐答案
使用参数-ViewSet在新设置的View中调用脚本
Call the Script in the new-set View with parameter -ViewSet
如果涉及到调用 setview
产生一个子外壳i n,您在脚本中定义的该子外壳将不可见.
If that involve calling cleartool setview
, don't: setview
spawns a subshell in which what you have defined in your script won't be visible.
当脚本需要访问动态视图已启动时,请使用 full 动态查看路径:
When your script needs to access the dynamic view started, do use the full dynamic view path:
/view/myDynView
# under which you would see:
/view/myDynView/vobs/MyVob
这篇关于将变量传递给调用自身的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!