2011년 4월 7일 목요일

how to list files in branch(es) in clearcase

Clear case users are supposed to report when (s)he finish his(her) work using clear case.
It's annoying job to list files (s)he touched in his(her) branch.
This is script tool that lists files created in the branch.

#!/bin/bash

function do_lst(){
echo
echo "branch $1:::"
CMD="cleartool find . -branch brtype($1) -print"
FLIST=`$CMD`
for LINE in $FLIST
do
echo ${LINE%@@*}
done
}

function title(){
echo Lister in Cleartool ver 1.0 by Newton Kim
}

function help(){
echo 'USAGE:lsct {-h|branch_name} ...'
echo -e "\t-h\tThis help screen"
}

title

if [ $# -eq "0" ]
then
help
echo ERROR:No branch is specified
exit 1
fi

case $1 in
-h)
help
exit 0
;;
esac

for var in "$@"
do
do_lst $var
done

2010년 11월 3일 수요일

how to change tab to spaces for all source coes!!

Lots of code conventions including java and webkit suggests 4-pace indentation.
However, it is irritating sometimes.
Some IDE (i.e, Vim) clarify indentation using tab by default.
It's hard for programmer who has habit of indentation by tab to change habit.
If we changed IDE settings and succeeded in urging programmer to change his/her habit, we still have problem.
If we have thousands of files in repository, It's really hard to find tab among them.

Such problems are beginning of this how-to.
I made script to change tab to 4-space for every source code(c/c++ and java).

Following is the script.


tab2spc
-------------------------------------------------------------------------------

#!/bin/bash

EXTS="*c *.cpp *.cc *.h *.hpp *.hh *.java"
FILES=""

for EXT in $EXTS
do
FILES+=`find . -name $EXT`
done

for FILE in $FILES
do
SRCFILE="$FILE".tab
mv $FILE $SRCFILE
echo $FILE...
sed 's/\t/ /g' < $SRCFILE > $FILE
unix2dos $FILE
rm $SRCFILE
done