Книга: UNIX — универсальная среда программирования

3.8.45 put

3.8.45 put
# put: install file into history
PATH=/bin:/usr/bin
case $# in
1) HIST=$1.H ;;
*) echo 'Usage: put file' 1>&2; exit 1 ;;
esac
if test ! -r $1
then
 echo "put: can't open $1" 1>&2
 exit 1
fi
trap 'rm -f /tmp/put.[ab]$$; exit 1 12 15
echo -n 'Summary: '
read Summary
if get -o /tmp/put.a$$ $1 # previous version
then # merge pieces
 cp $1 /tmp/put.b$$ # current version
 echo `getname` `date` $Summary" >>/tmp/put.b$$
 diff -e $1 /tmp/put.a$$ >>/tmp/put.b$$ # latest diffs
 sed -n '/^@@@/,$р' <$HIST >>/tmp/put.b$$ # old diffs
 overwrite $HIST cat /tmp/put.b$$ # put it back
else # make a new one
 echo "put: creating $HIST"
 cp $1 $HIST
 echo "@@@ `getname` `date` $Summary" >>$HIST
fi
rm -f /tmp/put.[ab]$$

Оглавление книги


Генерация: 0.225. Запросов К БД/Cache: 0 / 2
поделиться
Вверх Вниз