#!/bin/sh
# Set target string, files to search, location of p4 executable...
TARGET='\r\n'
DEPOT_PATH="//depot/src/..."
CHANGE=$1
P4CMD="/usr/local/bin/p4 -p 1666 -c copychecker"
XIT=0
echo ""
# For each file, strip off #version and other non-filename info
# Use sed to swap spaces w/"%" to obtain single arguments for "for"
for FILE in `$P4CMD files $DEPOT_PATH@=$CHANGE | \
sed -e 's/\(.*\)\#[0-9]* - .*$/\1/' -e 's/ /%/g'`
do
# Undo the replacement to obtain filename...
FILE="`echo $FILE | sed -e 's/%/ /g'`"
# ...and use @= specifier to access file contents:
# p4 print -q //depot/src/file.c@=12345
if $P4CMD print -q "$FILE@=$CHANGE" | fgrep "$TARGET" > /dev/null
then
echo "Submit fails: '$TARGET' not found in $FILE"
XIT=1
else
echo ""
fi
done
exit $XIT
对于the p4 docs中的bash示例,以下是我可以进行的最小编辑:
如果缺少目标,原始示例将失败;如果仅切换
if
的then
和else
分支,则此示例将失败。当然,您可以进一步编辑它(例如,如果您的grep像GNU一样支持它,那么就给grep
,或者fgrep
标志来抑制输出)。在相关问题 更多 >
编程相关推荐