mql-check-binary-surprises/check-surprises.sh

47 lines
1.1 KiB
Bash

#!/bin/bash
# Check if the current directory is already a git repository
if [ -d ".git" ]; then
echo "Error: Git repository already exists."
exit 1
fi
# Check if .gitignore already exists in the current directory or any subdirectory
gitignore_path=$(find . -name ".gitignore" -print -quit)
if [ -n "$gitignore_path" ]; then
echo "Error: .gitignore file already exists at '$gitignore_path'."
exit 1
fi
# Create .gitignore file
cat <<EOL > .gitignore
*
!*.mqh
!*.mq5
!*.mq4
!*/
!**/*.mqh
!**/*.mq5
!**/*.mq4
EOL
# Initialize git repository
git init
# Add all files to the staging area
git add .
# Count how many files are in the index
file_count=$(git ls-files | wc -l)
echo "Number of files in the index: $file_count"
# Execute the command to check eolinfo for files in the index
broken_files=$(git ls-files --format='%(eolinfo:index) %(path)' | column -t | grep '\-text')
# Check if any broken files were found and print the appropriate message
if [ -z "$broken_files" ]; then
echo "No broken files found."
else
echo "Broken files:"
echo "$broken_files"
fi