Added an infinite loop after updating packages. #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This prevents control from returning to the parent shell, which might in turn try to execute commands found inside PS1 and PROMPT_COMMAND.
My tests showed that adding this loop is sufficient to stop issues like msys2/MSYS2-packages#373. Commit 3f3ecb3 (which sets PS1 and PROMPT_COMMAND to safe values) might not even be necessary any more if we add this infinite loop, but it's good to keep that just in case. To test this loop, I opened a fresh copy of msys64 (extracted from the .tar.xz file), added my loop to /usr/bin/update-core, ran update-core, then closed the window, and everything was fine even though my PS1 had shell commands in it.
One annoying thing is that when I click on the "X" to close the Window after updating packages, MinTTY detects that update-core is still running and it shows a message box to ask if I really want to quit. That is unfortunate but I hope that our users are smart enough to click "OK".
This is cleaner than turning update-core into a shell function, because doing it that way puts environment variables like TEXTDOMAIN and shell functions like msg into the scope of the user's current shell even if no packages are updated. (I tested this claim to verify it is true.)
Sorry for making 3 pull requests instead of thinking ahead a little bit and just making one.