Replace ls with more safe find | read, check for .git presence
This commit is contained in:
parent
7bfe8aaf58
commit
7079595fbc
20
update.sh
20
update.sh
@ -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.
|
||||
|
||||
# Path to the directory with mods
|
||||
MODS_PATH=.
|
||||
#Move to the parent directory so the script can self update.
|
||||
cd ..
|
||||
|
||||
#Define MODS as a listing of all the subdirectories
|
||||
MODS=`ls`
|
||||
|
||||
for i in ${MODS}; do
|
||||
echo "$i" #Prints the current directory, useful for debugging and logs, pointless right now.
|
||||
cd $i #Moves into the current directory, VERY IMPORTANT
|
||||
git pull #Runs the update call for GIT
|
||||
cd ..; #Moves back up to the parent directory
|
||||
find $MODS_PATH -maxdepth 1 -type d -print0 | while read -d $'\0' dir
|
||||
do
|
||||
echo "$dir" #Prints the current directory, useful for debugging and logs, pointless right now.
|
||||
cd "$dir" #Moves into the current directory, VERY IMPORTANT
|
||||
if [[ -d .git ]]; then
|
||||
git pull #Runs the update call for GIT
|
||||
else
|
||||
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
|
||||
|
||||
#Now that all files are updated copy them to the main directory.
|
||||
|
Loading…
x
Reference in New Issue
Block a user