clone-repo.sh 608 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. repo=$1
  3. output=${2:-""}
  4. outputDefault="src"
  5. src=$([ "$output" = "" ] && echo $outputDefault || (echo $output))
  6. if [ ! -d ${src} ] ; then
  7. mkdir ${src}
  8. fi
  9. cd ${src}
  10. # ---------- ---------- ---------- ---------- ---------- ----------
  11. #NOTE: The following catches errors without halting the entire process.
  12. #
  13. # Credit:
  14. # http://bobbelderbos.com/2012/07/simple-bash-script-to-clone-remote-git-repositories/
  15. #
  16. # ---------- ---------- ---------- ---------- ---------- ----------
  17. cloneCmd="git clone ${repo}"
  18. cloneCmdRun=$($cloneCmd 2>&1)
  19. echo -e "Running: \n$ $cloneCmd"
  20. echo -e "${cloneCmdRun}\n\n"