git2unix.sh 690 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. cat <<END >>/dev/null
  3. touch git2unix &&
  4. echo "bash `pwd`/git2unix.sh" >git2unix &&
  5. chmod +x git2unix &&
  6. sudo rm -f /bin/git2unix &&
  7. sudo mv git2unix /bin/git2unix
  8. END
  9. dos2unix -V>/dev/null 2>&1
  10. ret=$?; if [[ 0 -ne $ret ]]; then
  11. echo "dos2unix not found."
  12. echo " sudo yum install -y dos2unix"
  13. exit $ret
  14. fi
  15. files=`git status|egrep "(modified|new file)"|awk -F ':' '{print $2}'|awk '{print $1}'|egrep "(.hpp$|.cpp$|.cc$|.h$|.c$|.txt$|.sh|.conf$)"`;
  16. for file in $files; do
  17. dos2unix $file;
  18. echo $file|grep ".sh$" >/dev/null 2>&1; EOF_SH=$?
  19. if [[ $EOF_SH -ne 0 && -f $file ]]; then
  20. echo "chmod -x $file"
  21. chmod -x $file;
  22. fi
  23. done