#!/bin/sh [ "$#" -lt 1 ] && echo "error: invalid usage: requires an arugement" && exit 1 set -e bak="$1.original" if [ -e "$bak" ]; then echo -n "$bak exists! replace? (y/N): " read input [ ! "$input" = "y" ] && exit 0 fi cp "$1" "$bak" echo "info: created backup file $bak" [ -z $EDITOR ] && echo "error: EDITOR is not set. attempting to use vi" && export EDITOR=vi $EDITOR "$1"