Skip to content

Instantly share code, notes, and snippets.

@nulltask
Created February 23, 2012 18:01
Show Gist options
  • Select an option

  • Save nulltask/1894051 to your computer and use it in GitHub Desktop.

Select an option

Save nulltask/1894051 to your computer and use it in GitHub Desktop.
RCS wrapper for vi written by POSIX-shell script
#!/bin/sh
#
# rcsvi
#
# @author Seiya Konno <seiya@uniba.jp>
#
target=$1
if [ "$target" = "" ] ; then
exit -1
fi
if [ ! -f "$target" ] ; then
exit -1
fi
tmpdir="/tmp/rcsvi"
if [ ! -d $tmpdir ] ; then
mkdir -p $tmpdir
chmod 777 $tmpdir
fi
rcsdiff "$target"
ret=$?
if [ $ret -eq 1 ] ; then
echo -n "difference is detected! commit before editing? (Y/n/c) > "
read ans
basetarget=`basename $target`
while :
do
case $ans in
[Yy] )
cp -p "$target" "$tmpdir/$basetarget.$$"
yes | co -l "$target"
cp -fp "$tmpdir/$basetarget.$$" "$target"
ci -u "$target"
break
;;
[Nn] )
break
;;
[Cc] )
exit -1
;;
esac
done
elif [ $ret -eq 2 ] ; then
rcsdir=`dirname $target`/RCS
if [ ! -d $rcsdir ] ; then
mkdir $rcsdir
fi
ci -u "$target"
elif [ $ret -ne 0 ] ; then
exit -1
fi
co -l $1 && vim $1 && ci -u $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment