您的位置:軟件測試 > 開源軟件測試 > 開源配置管理工具 > cvs
CVS-RCS
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時間:[ 2013/1/25 16:19:35 ] 推薦標(biāo)簽:

4.1 sget

注意 : Korn shell /bin/ksh 在你從Linux CD-ROM 安裝 pdksh*.rpm 時會產(chǎn)

請把他存成一般文字檔并改變存取權(quán)限 chmod a+rx
_________________________________________________________________

#!/bin/ksh

# CVS program sget
# Program to check out the file from CVS read-only

cmdname=`basename $0`

Usage()
{
print " Usage: $cmdname [-r revision_number/symbolic_tag_name]
irectory name> "
print "The options -r are optional "
print "For example - "
print " $cmdname -r 1.1 foo.cpp"
print " $cmdname foo.cpp "
print " $cmdname some_directory "
print "Extract by symbolic revision tag like - "
print " $cmdname -r REVISION_1 some_directory "
print " "
exit
}

# Command getopt will not supported in next major release.
# Use getopts instead.
while getopts r: ii
do
case $ii in
r) FLAG1=$ii; OARG1="$OPTARG";;
?) Usage; exit 2;;
esac
done
shift ` expr $OPTIND - 1 `

#echo FLAG1 = $FLAG1 , OARG1 = $OARG1

if [ $# -lt 1 ]; then
Usage
fi

bkextn=sget_bak

hme=` echo $HOME | cut -f1 -d' ' `
if [ "$hme" = "" ]; then
print " Error: $HOME is not set!! "
exit
fi

# Check if file already exists....
if [ -f $1 ]; then
user_perms=" "
group_perms=" "
other_perms=" "
user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
if [ "$user_perms" = "w" -o "$group_perms" = "w"
-o "$other_perms" = "w" ]; then
print " Error: The file is writable. Aborting $cmdname ......"
print " You should either backup, scommit or delete the f
ile and"
print " try $cmdname again "
exit
fi
fi

cur_dir=`pwd`
#echo $cur_dir

len=${#hme}
len=$(($len + 2))
#echo $len

subdir=` echo $cur_dir | cut -b $len-2000 `
#echo $subdir

if [ "$subdir" = "" ]; then
fdname=$1
else
fdname=$subdir"/"$1
fi

# Move the file
touch $1 2>/dev/null
mv -f $1 $1.$bkextn

# Create subshell
(
cd $hme
#echo $fdname

# Use -A option to clear all sticky flags
if [ "$FLAG1" = "" ]; then
cvs -r checkout -A $fdname
else
cvs -r checkout -A -$FLAG1 $OARG1 $fdname
fi
)
#pwd

if [ -f $1 ]; then
print " READ-ONLY copy of the file $fdname obtained."
print "Done $cmdname"
#print " Tip (Usage): $cmdname "
fi

上一頁12345678910下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd