Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add script to fix files in the future

  • Loading branch information...
commit e4ba76779983fa26eea3dca43ea08c9373350698 1 parent f9b8f7f
@cwensley cwensley authored
Showing with 60 additions and 1 deletion.
  1. +1 −1  .gitattributes
  2. +59 −0 Resources/fixfiles.sh
View
2  .gitattributes
@@ -1,2 +1,2 @@
/Resources/MacAppTemplate.app/Contents/MacOS/* eol=lf
-
+*.sh eol=lf
View
59 Resources/fixfiles.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+function tounix () {
+ for f in $1
+ do
+ echo "Processing $f"
+ # remove BOM
+ awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' "$f" >> /dev/null
+
+ # CRLF to LF
+ perl -pi -e 's/\r\n/\n/g' "$f"
+
+ done
+}
+
+function towindows () {
+ for f in $1
+ do
+ echo "Processing $f"
+ # remove BOM
+ awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' "$f" >> /dev/null
+
+ # LF to CRLF
+ perl -pi -e 's/\r\n/\n/g' "$f"
+ perl -pi -e 's/\n/\r\n/' "$f"
+ done
+}
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+SOURCE_DIR=$DIR/../Source
+
+source_files=$(find $SOURCE_DIR -name *.cs)
+project_files=$(find $SOURCE_DIR -name *.csproj)
+
+if [ "$1" == "win" -o "$1" == "windows" ]
+then
+ towindows "$source_files"
+ towindows "$project_files"
+
+elif [ "$1" == "unix" ]
+then
+ tounix "$source_files"
+ tounix "$project_files"
+
+else
+
+echo
+echo "This script is used to ensure all files follow platform conventions"
+echo "when sharing code between Windows and *nix systems, and removes the BOM"
+echo "from all files."
+echo
+echo "usage: ./fixfiles.sh (unix|windows)"
+echo
+echo " windows: use windows CRLF line endings"
+echo " unix: use unix LF line endings"
+
+fi
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.