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.
- keeps all user.js.parrot lines intact
- keeps empty lines intact
- fix for keeping `!` and `^` in non-"user_pref" lines intact
+ some other minor changes + streamlining
https://github.com/ghacksuserjs/ghacks-user.js/issues/264#issuecomment-345462158
- It can now handle read-only files.
- it is somewhat more explicit regarding what it's doing in some circumstances. For example, it now informs the user when no changes are made.
- It now accepts two parameters: `-unattended` and `-log`
- Minor improvements here and there.