Article View: comp.editors
Article #2769Re: save backups of vi files?
From: Bill Petro
Date: Thu, 06 Jun 1991 07:47
Date: Thu, 06 Jun 1991 07:47
46 lines
1514 bytes
1514 bytes
jerrys@truevision.com (Jerry Schwartz) writes:
>Is there any way to have a backup of the file you are
>editing saved automatically with vi. I tried set directory, but
>that only saves it while the session is open.
> Jerry Schwartz
> jjs@epicb.truevision.com
>P.S. I know that Tom can answer this one.
Here is "vv" that makes a backup file for you.
#!/bin/sh
if test -z "$FAVEDITOR"; then
FAVEDITOR=/usr/ucb/vi
fi
case $# in
0) $FAVEEDITOR # no file, invoke editor w/o arg
exit;;
1) EDITFIL=$1;;
*) echo "Usage: vv [editfile]"
exit 1;;
esac
EDITERR=editerr
TEMPFIL=/tmp/`logname`.$$
if test -r $EDITFIL; then
cp $EDITFIL $TEMPFIL
if $FAVEDITOR $EDITFIL; then
mv $TEMPFIL ${EDITFIL}.bak
echo "Backup file created"
else
mv $TEMPFIL $EDITERR
echo edit error: original file is in $EDITERR
fi
else
$FAVEDITOR $EDITFIL
fi
--
Bill Petro {decwrl,hplabs,ucbvax}!sun!Eng!rock
"UNIX for the sake of the kingdom of heaven" Matthew 19:12
Technical Details
Message-ID:
<14633@exodus.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!geraldo.Central.Sun.COM!male!jethro!exodus!warp.Eng.Sun.COM!rockReferences:
<1991Jun05.223821.13404@truevision.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!geraldo.Central.Sun.COM!male!jethro!exodus!warp.Eng.Sun.COM!rock From: rock@warp.Eng.Sun.COM (Bill Petro) Newsgroups: comp.editors Subject: Re: save backups of vi files? Message-ID: <14633@exodus.Eng.Sun.COM> Date: 6 Jun 91 07:47:03 GMT References: <1991Jun05.223821.13404@truevision.com> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Inc. Lines: 46