ClearCase:这是一个错误还是一个功能?
当我从 bash 交互运行以下代码时,它工作正常。
cleartool setview $myview
cleartool lsbl
但是当我将它们放入脚本并尝试运行该脚本时,它永远不会从第一个cleartool命令返回。
在交互式情况下,第一个cleartool命令似乎打开了一个新的bash来运行,当您从新的shell运行第二个命令时,它工作正常。但在脚本的情况下,新的 shell 不可见,因此它似乎不会从命令返回。
有没有办法将cleartool命令保留在它们运行的同一个bash shell中?
When I run the following code intereactively from bash it works fine.
cleartool setview $myview
cleartool lsbl
But when I put them in a script and try to run the script, it never returns from the first cleartool command.
It seems in the interactive case the first cleartool command opens a new bash to run in and when you run the second command from the new shell it works fine. But in case of the script the new shell is not being visible and hence it seems not to return from the command.
Is there anyway to keep the cleartool commands in the same bash shell they are running from?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cleartool setview
命令打开一个新的交互式 shell。在该 shell 中,当您手动键入第二个命令时,您将执行该命令。当您将这两行放入脚本中时,setview
会执行 shell 等待您的输入。一旦退出该 shell,就会执行第二个命令。当然,第二个命令不是在$myview
上下文中执行的。为了使事情更清晰,请执行以下操作:在 shell 中执行
cleartool setview $myview
五次。在每个setview
之后输入echo $$
。这将为您提供当前 shell 的进程 ID。数字将会增加。然后在每个 shell 中输入exit
。每次退出
后再次echo $$
。旧号码将以降序显示。六次退出后,您的终端应该关闭。这就是解释。您的问题的解决方案可能是
setview
命令的-exec
选项:应该可以解决问题。
The
cleartool setview
command opens a new interactive shell. In that shell you execute the second command when you type it by hand. When you put both lines into a script, thesetview
executes the shell waiting for your input. The second command is executed as soon as you exit that shell. Of course the second command is not executed in the context of$myview
.To make things a little bit clearer do the following: In a shell execute
cleartool setview $myview
five times. Typeecho $$
after eachsetview
. This gives you the process ID of the current shell. The numbers will increase. Then typeexit
in each shell. Doecho $$
again after eachexit
. The old number will appear in decreasing order. After sixexit
s you terminal should be closed.That was the explanation. A solution for your problem might be the
-exec
option of thesetview
command:should do the trick.
虽然它没有直接回答问题,但以下内容可能会满足您的要求。它使第二个命令在第一个命令打开的子 shell 中运行。
While it doesn't directly answer the question, the following might do what you want. It makes the second command run in the subshell that the first command opens.