Replace ls with more safe find | read, check for .git presence

This commit is contained in:
donat_b 2014-10-08 23:02:50 +04:00
parent 7bfe8aaf58
commit 7079595fbc

View File

@ -2,17 +2,21 @@
#This script should pull a list of the directories in the parent folder, cd into each folder issue the Git Update command, update the files, move back to the parent directory and repeat until all files have been updated, then copy the files to the main mod directory. #This script should pull a list of the directories in the parent folder, cd into each folder issue the Git Update command, update the files, move back to the parent directory and repeat until all files have been updated, then copy the files to the main mod directory.
# Path to the directory with mods
MODS_PATH=.
#Move to the parent directory so the script can self update. #Move to the parent directory so the script can self update.
cd .. cd ..
#Define MODS as a listing of all the subdirectories find $MODS_PATH -maxdepth 1 -type d -print0 | while read -d $'\0' dir
MODS=`ls` do
echo "$dir" #Prints the current directory, useful for debugging and logs, pointless right now.
for i in ${MODS}; do cd "$dir" #Moves into the current directory, VERY IMPORTANT
echo "$i" #Prints the current directory, useful for debugging and logs, pointless right now. if [[ -d .git ]]; then
cd $i #Moves into the current directory, VERY IMPORTANT git pull #Runs the update call for GIT
git pull #Runs the update call for GIT else
cd ..; #Moves back up to the parent directory printf 'Not a git repository\n'
fi
cd .. #Moves back up to the parent directory
done #Once all directories have cycled through this ends the loop done #Once all directories have cycled through this ends the loop
#Now that all files are updated copy them to the main directory. #Now that all files are updated copy them to the main directory.