Passing a Variable to a script calling itself

不打扰是莪最后的温柔 提交于 2019-12-17 19:55:39

问题


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
    }

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.

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.


回答1:


Call the Script in the new-set View with parameter -ViewSet

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.

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


来源:https://stackoverflow.com/questions/33932151/passing-a-variable-to-a-script-calling-itself

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!