cp_dir 229 B

123456789101112131415161718
  1. #!/bin/sh
  2. set -e
  3. trap "rm -f /tmp/xx$$" 0 1 2 3 15
  4. case $2 in
  5. /*) target_dir=$2
  6. ;;
  7. *) target_dir=`pwd`/$2
  8. ;;
  9. esac
  10. cd $1
  11. tar cf /tmp/xx$$ .
  12. if [ -d $target_dir ]
  13. then :
  14. else mkdir $target_dir
  15. fi
  16. cd $target_dir
  17. tar xf /tmp/xx$$