You are missing a do
after the second while
. (The 'B' case; compare that against the 'A' case above it.)
I use gvim which will syntax highlight shell scripts, but I think you need to ask about editors as a separate question.
As for your modified question:
Your logic is broken in both the A
and B
cases: you need to pull the backup logic out of your if/while nesting... the if
isn't actually doing anything for you. Also, be sure to quote all your filenames so that spaces don't break your script. Escape your nested quotes. I believe you need a -e
on the echo statements that use \c
.
So do something more like:
b|B) echo -e "Specify the ordinary file for backup and hit <Enter>: \c"
read file
while [ ! -f "$file" ]
do
echo "Usage: \"$file\" must be an ordinary file."
echo -e "Specify the ordinary file for backup and hit <Enter>: \c"
read file
if [ "$file" = "q" -o "$file" = "Q" ]
then
exit 0
fi
done
cp "$file" "$file.bkup"
;;
You'll need to do the same kind of change for the A
case.