#! /bin/sh

mode=755
while test $# -gt 0; do
  case "$1" in
  -c);;
  -m) shift; mode="$1";;
  *) break;;
  esac
  shift
done

if test -d "$2"; then
  file="$2/`basename "$1"`"
else
  file="$2"
fi

if test -d "$1"; then
  mkdir -p "$file"
  for f in `ls "$1"`; do
    "$0" -m "$mode" "$1/$f" "$file"
  done
else
  cp "$1" "$2";
  if test -f "$file"; then chmod "$mode" "$file"; fi
fi
