sh – Testable and self-contained bash script

I wrote a short bash script for a completion check of downloading images. If you have any good ideas, please tell me them. Thank you.

#!/bin/sh

# if a directory name is assigned

if [ $# -eq 1 ]; then

  a=`ls -1 $1/*.jpg | wc -l`
  b=`grep jpg $1/tmp.sh | wc -l`
  if [ $a = $b ]; then
    echo $1
  fi
  exit
fi

# if some directory names are assigned

if [ $# -gt 1 ]; then
  for dir1 in "$@"; do
    ./done.sh $dir1
  done
fi

# if directory names are not assigned

if [ $# -eq 0 ]; then
  ls -d */ | xargs ./done.sh
fi