winlin

add git2unix script

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