http://www-01.ibm.com/support/docview.wss?uid=swg21119859
Problem(Abstract)
This technote explains why setting into an IBM® Rational® ClearCase® view from within a UNIX® or Linux® shell script does not process the remaining commands in that script.
Cause
When running the sample script below, all commands executed after the cleartool setviewcommand are not processed because cleartool setview spawns a new shell:
#!/bin/sh
/usr/atria/bin/cleartool setview cmview
/usr/atria/bin/cleartool pwv
/usr/atria/bin/cleartool lsview
cd /vob/transition/Admin_transition
/usr/atria/bin/cleartool mkbrtype -global -nc 02b456
In the above script any commands that appear after the execution of cleartool setview cmvieware not processed because a shell is spawned off with exec(), which replaces the current program with a new program.
This means current process's text and code segments, which in this case is the script that contains all the commands, is replaced by the program getting executed, which is the shell invoked by runningcleartool setview cmview. Hence, none of the commands are processed beyond the point of invocation of the setview.
Resolving the problem
This is the expected behavior.
WORKAROUNDS:
- Run cleartool setview prior to calling the script:
Example:
$ cat /tmp/script.sh
#!/bin/sh
/usr/atria/bin/cleartool pwv
$ cleartool setview new_view
[new_view]$ /tmp/script.sh
Working directory view: new_view
Set view: new_view - Run the cleartool setview command and exec into the script:
Example:
$ cleartool setview -exec /tmp/script.sh new_view
Working directory view: new_view
Set view: new_view
-------------------
A quick example is:
cleartool setview -exec "/usr/local/bin/myscript.sh"
$myview