These Bash shell scripts automate some ClearCase tasks that are performed frequently. The software development environment in which these scripts will run is listed below.
I tend to checkout many files at once because I may edit them during development. After I finish my development, I need to uncheckout only those files that I did not change. This is the most useful script I wrote for ClearCase. You have to try this yourself.
The input to this script is a list of file paths separated by newlines. The script checks whether each file is different from its previous version. If the file is identical, then it is unchecked out.
The script uncheck-unchange.sh:
#!/bin/bash
noChange=0 ### "cleartool diff" exit status means no difference
while read elem; do
cleartool diff -pre -options "-status_only" "$elem"
if [ $? = $noChange ]; then
cleartool uncheckout -rm "$elem"
fi
done
find-checkout.sh | uncheck-unchange.sh
All my previously mounted VOB's would disappear frequently. I don't really know why. So this script mounts them again without too much hassle.
The script mount-my-vob.sh:
#!/bin/bash
### mount my clearcase vobs
vobs="\app1 \library2 \tool3"
for elem in $vobs; do
echo $elem
cleartool mount -persistent $elem
echo '----'
done
Recursively find all checked-out files from a list of directories specified as command-line parameters. The output is a list of file paths separated by newlines.
For example:
find-checkout.sh dir1 dir2
#!/bin/bash
### list all checked-out files, recursively;
### the output pathnames are in unix format;
### find-checkout.sh [dir1 dir2 ...]
cleartool lscheckout -recurse -short -me -cview $@ | sed 's/\\/\//g'
Find view-only files from a list of directories specified as command-line parameters. The search is recursive and includes view-private files, view-private directories, view-private links, and checked-out files.
For example:
find-view-only.sh dir1 dir2
#!/bin/bash -x
### find view-only files: view-private files,
### view-private dirs, view-private links,
### checked-out versions
cleartool ls -view_only -short -recurse $@