#!/bin/sh
# edit with locking
if [ "$1" = "" ]; then
cat <<EOD;
edit with (POSIX) locking
usage: `basename $0` filename [options]
options may be any of your \$EDITOR options
EOD
exit
fi
file=$1
shift
if [ ! -f $file ]; then
echo "$0: $file does not exist" >&2
exit 1
fi
if [ ! -w $file ]; then
echo "$0: $file is not writeable" >&2
exit 1
fi
wlock -s $file ${EDITOR:-vi} "$@" $file || wlock -vt $file