How can I add commands to be executed when setting a view?

378 Views Asked by At

Using cleartool, when you cleartool setview, a subshell is opened apparently (you can exit it and leave the view). I was wondering - how can I get more commands to be executed, or settings made, when this subshell starts? Of course, I don't mean code which executes when any shell starts, just when cleartool starts one.

2

There are 2 best solutions below

2
VonC On

A cleartool setview does not source anything (any shrc/bashrc) when spawning its subshell.

I have always advised against setview, precisely to avoid the subshell issue.

It would be easier to get a script which would:

  • execute/source additional commands
  • switch the full view path /view/AViewName/vobs/aVob/... instead of relying on the /vobs setview chroot trick.

Or, use the -exec option of setview to source settings and execute a script.

0
Brian Cowan On

According to the man page for setview, it takes an -exec parameter.

https://www.ibm.com/support/knowledgecenter/SSSH27_9.0.1/com.ibm.rational.clearcase.cc_ref.doc/topics/ct_setview.htm

That can be used to run a script if you wish. As @Vonc mentioned, setview is a chroot environment, and the root of a view (/view/myview) will show the / filesystem to transparently support the chroot.

If you're scripting things on Unix, and want to follow VonC's advice about not using setview, you would need to set/detect a view in the script. "cleartool pwv -wdview" will tell you the view context of the current working directory. (See https://www.ibm.com/support/knowledgecenter/SSSH27_9.0.1/com.ibm.rational.clearcase.cc_ref.doc/topics/ct_pwv.htm)

From personal experience, it's usually not a good idea to reach between views during audited builds, if that is what your script does. But some people use a common view for trigger scripts under source control...