📄 incbuild
字号:
#!/bin/sh
######################################################################
#
# File: incbuild file
# Purpose: Script to increment BRD_BUILD variable
#
# Notes: This script works only with a file that contains the
# following lines in this exact order:
#
# const int BRD_BUILD = X ;
# const char BRD_TIME = __TIME__ ;
# const int BRD_DATE = __DATE__ ;
#
# This script knows exactly which piece is the variable
# to increment. Do not attempt to use with any other
# type of file. It will not work!
#
# It is ideal to write a more robut script that is able
# to find BRD_BUILD and replace the value in the file
# but this will do for now...
#
######################################################################
chmod o+w $1
#
# Step 1) Check for valid filename/argument
#
if [ $# = 0 ]
then
echo usage: $0 filename
exit
fi
if [ ! -r $1 ]
then
echo error: $1 is not readable!
exit
fi
if [ ! -w $1 ]
then
echo error: $1 is not writable!
exit
fi
#
# Step 2) Parse out current value
#
position=0
for piece in `cat $1`
do
position=`expr ${position} + 1`
if [ ${position} = 5 ]
then
build=`expr ${piece}`
build=`expr ${build} + 1`
fi
done
#
# Step 3) Now update file with new build number
#
echo const int BRD_BUILD = ${build} \; > $1
echo const char BRD_TIME[] = __TIME__ \; >> $1
echo const char BRD_DATE[] = __DATE__ \; >> $1
echo BRD_BUILD = ${build}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -