safeedit (389B)
1 #!/bin/sh 2 3 [ "$#" -lt 1 ] && echo "error: invalid usage: requires an arugement" && exit 1 4 5 set -e 6 7 bak="$1.original" 8 9 if [ -e "$bak" ]; then 10 echo -n "$bak exists! replace? (y/N): " 11 read input 12 [ ! "$input" = "y" ] && exit 0 13 fi 14 15 cp "$1" "$bak" 16 echo "info: created backup file $bak" 17 18 [ -z $EDITOR ] && echo "error: EDITOR is not set. attempting to use vi" && export EDITOR=vi 19 $EDITOR "$1"