Update updater.sh

- always wrap variables in quotes when dealing with filepaths (for good measure)
- don't append when initially creating the temp file (= easier to test the function in a standalone script without having to worry about cleanup)
This commit is contained in:
earthlng 2018-11-21 15:26:15 +00:00 committed by GitHub
parent 31989ccb35
commit 1de3634d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,8 +172,8 @@ backup_file () {
if [ $BACKUP = "single" ]; then
bakname="userjs_backups/${filename}.backup"
fi
mv $filename $bakname
mv "userjs_temps/${filename}" $filename
mv "$filename" "$bakname"
mv "userjs_temps/${filename}" "$filename"
echo -e "Status: ${GREEN}${filename} has been backed up and replaced with the latest version!${NC}"
}
@ -305,7 +305,7 @@ update_userjs () {
remove_comments () {
if [ $MINIFY = "true" ]; then
sed -n 1,8p user.js >> userjs_temps/no_comments.js # Add header
sed -n 1,8p user.js > userjs_temps/no_comments.js # Add header
echo "******/" >> userjs_temps/no_comments.js # Add end of comment
# Remove comments and empty lines
sed -e 's/\s*\/\/ .*$//' -e 's|/\*|\n&|g;s|*/|&\n|g' -e '/\/\*/,/*\//d' -e '/^\s*$/d' -e '/^[[:space:]]*$/d' user.js >> userjs_temps/content.js