#!/bin/bash -e
tmp=".vi-.$$.tmp"
if [ -n "$1" ]; then
    for L; do echo "$L"; done >"$tmp"
    touch "$tmp" -d '1 second ago'
    cp -a "$tmp" "$tmp.orig"
fi
"${EDITOR:-vi}" "$tmp" </dev/tty >/dev/tty
[ -e "$tmp" ]
[ ! -e "$tmp.orig" -o "$tmp" -nt "$tmp.orig" ]
(rm "$tmp" ; cat) <"$tmp"
