#!/bin/sh

if [ $# -eq 0 ]; then
    echo "usage: $(basename $0) FILE ..." > /dev/stderr
    exit 1
fi

for FILE in $@; do
    case $FILE in
        *.bak) echo "warning: $FILE is a backup file";;
            *) if [ -f "$FILE" ]; then
                   /bin/cp $FILE $FILE.bak
               elif [ -d "$FILE" ]; then
                   echo "$FILE is a directory" > /dev/stderr
                   exit 1
               else
                   echo "$FILE: backup file not found" > /dev/stderr
                   exit 1
               fi;;
    esac
done
