📄 filecheckin.sh
字号:
#!/bin/ksh## SAMPLE NAME: fileCheckIn## FUNCTIONS: This sample shell script checks files into the CMVC tool.# It shows common files and constructs a File -checkin command# using common releases. The CMVC_RELEASE environment variable # must be set if the release name is not specified on the command# line.## USAGE: fileCheckIn filePathName [releaseName]## ENVIRONMENT# VARIABLE(S): CMVC_FAMILY [CMVC_RELEASE] [CMVC_BECOME]## 5765-207 (C) COPYRIGHT International Business Machines Corp. 1993,1994# 5765-202 (C) COPYRIGHT International Business Machines Corp. 1993,1994# 5622-063 (C) COPYRIGHT International Business Machines Corp. 1993,1994# 5765-397 (C) COPYRIGHT International Business Machines Corp. 1994# All Rights Reserved# Licensed Materials - Property of IBM## US Government Users Restricted Rights - Use, duplication or# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.### NOTICE TO USERS OF THE SOURCE CODE EXAMPLES## INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE# EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A# PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE# OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS,# IS WITH YOU. SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE# DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION# DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR# CORRECTION.## * RISC System/6000 is a trademark of International Business Machines# Corporation.## /usr/lpp/cmvc/samples/fileCheckIn##-----------------------------------------------+# Cleanup on exit or interrupt. |#-----------------------------------------------+terminate(){ cleanup exit 1}cleanup(){ rm -f $COMMAND $REMARKS $COMMON 2>/dev/null}yesno(){ read REPLY case "$REPLY" in n|no|N|NO) YESNO=no ;; *) YESNO=yes ;; esac}#-----------------------------------------------+# Begin program. Check for proper args or give |# usage. |#-----------------------------------------------+if [ $# -eq 0 ]then echo "\nusage: $0 filePathName [releaseName]\n" echo "This sample shell script checks files into the CMVC tool. " echo "It shows common files and constructs a File -checkin command" echo "using common releases. The CMVC_RELEASE environment variable" echo "must be set if the release name is not specified on the command" echo "line.\n" exit 1fiif [ -z "$CMVC_FAMILY" ]then echo "The CMVC family must be set with the CMVC_FAMILY environment variable." exit 1fi#-----------------------------------------------+# Setup the environment. |#-----------------------------------------------+trap 'echo "\n$0: Interrupted."; cleanup; exit 1' 2 3 15COMMAND=/tmp/cmd$$REMARKS=/tmp/rem$$COMMON=/tmp/fpc$$#-----------------------------------------------+# Check for the release off the cmd line or |# in the environment. Exit if neither. |#-----------------------------------------------+if [ -z "$2" ]then if [ -z "$CMVC_RELEASE" ] then echo "The Release must be set in environment or given on the command line." exit 1 else release=$CMVC_RELEASE fielse release=$2fiecho "File -checkin $1 -release $release\c" >>$COMMAND#-----------------------------------------------+# Resolve the path name of the file. What was |# given on the COMMAND line may be cheap. |#-----------------------------------------------+echo "Please wait..."path=`File -resolve $1 -release $release -quiet` || terminate[ "$path" != "$1" ] && echo "\nResolving '$1' to '$path'."#-----------------------------------------------+# This will become a special cmd to get common |# files. Binding is no longer a factor |#-----------------------------------------------+Report -vi FileV -raw -wh "nuDropDate is null and releaseName <> '$release' and nuVersionId=(select nuVersionId from FileView where nuPathName='$path' and releaseName='$release')" > $COMMONif [ -s $COMMON ]then awk -F"|" 'BEGIN { printf "\n%s\n", "There are common files associated with\n'$path'" printf "\n%-16.16s %-9.9s %-45.45s\n","Release","Version","Path" printf "%-16.16s %-9.9s %-45.45s\n\n","----------------",\ "---------",\ "---------------------------------------------" } { if (length($1) > 45) start = (length($1)-44) else start = 0; printf "%-16.16s %-9.9s %45.45s\n",$2,$4,substr($1,start) }' $COMMON echo "\nDo you wish to include all releases as common ? [yes] \c" yesno if [ "$YESNO" = "no" ] then #-----------------------------------------------+ # Put the force flag into the COMMAND and ask | # for the common releases. | #-----------------------------------------------+ echo " -force\c" >>$COMMAND echo "\n\nEnter the common release names: \c" read REPLY [ -n "$REPLY" ] && echo " -common $REPLY\c" >>$COMMAND else #-----------------------------------------------+ # Build all releases into the COMMAND | #-----------------------------------------------+ RELEASELIST=`cat $COMMON | awk -F"|" '{ if (NR != 1) print " " printf "%s",$2 }'` echo " -common $RELEASELIST\c" >>$COMMAND fielse echo "\nNo common files."fi#-----------------------------------------------+# Get the relative directory name. |#-----------------------------------------------+echo "\nEnter the relative path name, if any: \c"read REPLY[ -n "$REPLY" ] && echo " -relative $REPLY\c" >>$COMMAND#-----------------------------------------------+# Get the defect numbers |#-----------------------------------------------+echo "\nEnter the defect numbers, if any: \c"read REPLY[ -n "$REPLY" ] && echo " -defect $REPLY\c" >>$COMMAND#-----------------------------------------------+# Get the feature numbers |#-----------------------------------------------+echo "\nEnter the feature numbers, if any: \c"read REPLY[ -n "$REPLY" ] && echo " -feature $REPLY\c" >>$COMMAND#-----------------------------------------------+# Get the remarks. |#-----------------------------------------------+echo "\nEnter remarks, terminate with blank line or period:"while read linedo if [ -z "$line" -o "." = "$line" ] then break; fi echo $line >>$REMARKSdoneif [ -s $REMARKS ]then echo " -remarks - < $REMARKS\c" >>$COMMANDfi#-----------------------------------------------+# Run the COMMAND. |#-----------------------------------------------+CLEAN=`cat $COMMAND | awk '{printf("%s",$0)}'`echo "\nRunning..."echo "$CLEAN"sh -c "$CLEAN"cleanupexit 0# end of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -