home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume32
/
gaps
/
part01
/
unput
< prev
next >
Wrap
Text File
|
1992-09-20
|
991b
|
40 lines
#!/bin/sh
# GAPS version 4.0
# get and put system - by Nadav Har'El
# unput: unput the last version from history
trap 'chmod -w $HIST' 1 2 3 15
case $# in
1) case $1 in
*.H) HIST=$1;;
*) HIST=$1.H
esac
if test -f $HIST
then
chmod u+w $HIST
fi ;;
*) echo 'Usage: unput file' 1>&2; exit 1 ;;
esac
if test ! -r $HIST -o ! -f $HIST
then
echo "unput: can't open history file $HIST" 1>&2
exit 1
fi
if test `grep "^@@\^" $HIST 2>/dev/null | wc -l` -le 1
then
echo "$HIST has only one version or not an history file." 1>&2
echo "Unput failed." 1>&2
exit 1
fi
trap 'rm -f /tmp/unput.[abc]$$;chmod -w $HIST 2>/dev/null; exit 1' 1 2 3 15
get -1 -o /tmp/unput.a$$ $HIST # get previous version
awk -F\^ <$HIST >/tmp/unput.b$$ ' # find all diffs but last
/^@@\^/ { count++
if(count==1)print "removed version", $2 >"/tmp/unput.c'$$'" }
count >= 2
'
trap '' 1 2 3 15 # ignore signals
cat /tmp/unput.[ab]$$ >$HIST
cat /tmp/unput.c$$ 1>&2
rm -f /tmp/unput.[abc]$$
chmod -w $HIST