Just something simple

Hi, new to the forums and just need a little help, I have a sript to write and as far as I can see it should work fine but it refuses to run properly, it has issues with the end of a line but I see no issue, would anyone assist please, I just someone to seconed check I have not overlooked something (I realise some of the scripting is messy):

Here follows my script:

#!/bin/sh
>shar
case $# in
0) echo "1 Usage: enshar file [...] " >&2
;;
*) for file
do if [ -d $file ]
then echo "3 enshar: $file is a directory" >&2
elif [ ! -f $file ]
then echo "4 enshar: $file does'nt exist" >&2
elif [ ! -r $file ]
then echo "5 enshar: $file can't be read" >&2
elif [ $file = !EnShAr! ]
then echo "6 enshar: $file can't enshar" >&2
else
echo "cat > $file <<\!EnShAr!"
cat $file
echo "!EnShAr!"
echo "set `cksum $file`"
echo "cksum" $file`
check=$1
echo "test $1 = $check || echo $0: Bad cksum in $file >&2 " >> shar
echo "cat > $file <<\!EnShAr!" >> shar
fi
done
;;
esac

The following line is wrong :

do if [ -d $file ]

the correct syntax is

do
if [ -d $file ]

or

do ; if [ -d $file ]

Format your script, it will be more easy to read

#!/bin/sh
>shar
case $# in
   0) echo "1 Usage: enshar file [...] " >&2
      ;;
   *) for file
      do 
         if [ -d $file ]
         then echo "3 enshar: $file is a directory" >&2
         elif [ ! -f $file ]
         then echo "4 enshar: $file does'nt exist" >&2
         elif [ ! -r $file ]
         then echo "5 enshar: $file can't be read" >&2
         elif [ $file = !EnShAr! ]
         then echo "6 enshar: $file can't enshar" >&2
         else
              echo "cat > $file <<\!EnShAr!"
              cat $file
              echo "!EnShAr!"
              echo "set `cksum $file`"
              echo "cksum" $file`
              check=$1
              echo "test $1 = $check || echo $0: Bad cksum in $file >&2 " >> shar
              echo "cat > $file <<\!EnShAr!" >> shar
         fi
      done
      ;;
esac

I have tried to add the correct syntax as you suggested and it grumbles that is unexpected, what am I doing wrong please?

echo "cksum" $file`

You have an unmatched trailing backquote.

This looks wrong to me:

echo "cksum" $file`

Okay thanks very much