Changes:
-The script doesn't touch the user.js file until it really has to.
-The merge function is a bit smarter parsing files, at no significant cost. See examples below.
-Minor syntactic changes here and there.
Additions:
-New -multiBackups argument. I personally intend to use it to compare files and quickly review changes.
Fixes:
- Merge function:
*no longer has the potential to truncate super long lines.
*no more issues with exclamation marks in user_pref lines.
Improvements:
- Overall better performance due to ECHO syntax changes.
- Merge function on steroids! Faster than ever, and no longer generates temporary files at all. As it always should have been.
Changes, Additions, Substractions:
- Leading spaces are no longer ignored by the merge function. Lines to be merged must begin with user_pref.
- Added header with name, author, version.
- Added help sub-menu.
- Added special message when no override files are found when using -multiOverrides.
- Formatting changes.
-updatebatch now will (or at least should):
*Download new batch and name it [updater]*.bat
*Open that script in a new CMD window.
*Exit
The [updated]*.bat script should:
*Copy itself overwriting the original batch (without renaming).
*Start that script in a new CMD instance.
*Exit.
The new script, with the original name, should:
*Delete the [updated]*.bat script
*Begin the normal script routine.
@earthing do you think I should still rename the scripts to .old or something before overwriting/deleting?
It ended up being a mixture of the previous commit and the fix. It writes a temporary file on the go that only holds preferences, and generates the target file at once at the end. It's slower than before, but it works.
While I figure out a fix for the missing characters...
Enclosing the whole merging loop in parentheses and replacing the source file with the entire output at once is more efficient than appending individual lines with >>%~2. The script doesn't have to wait for the HD to continue processing.
Everything in a line after a powershell call is considered as being called from PowerShell.
>nul didn't work because of that. Enclosing the line in brackets should fix it.
To account for the possibility of the user running the script silently in the background. PAUSE would leave an instance in memory doing nothing indefinitely.
I was going to use TIMEOUT but PING performs better.