Artificial intelligent assistant

Why does this bash script terminate the calling process when it ends? When this bash script is run _backgrounded_ , it terminates the calling shell. Why is this? #!/bin/bash # # weird job control, background termination of parent shell problem set -eum echo "Do not go gentle into that good night" sleep 1 Save this as `wat`, `chmod +x wat`, run it as `wat` \- no problem. Run it _backgrounded_ : wat & It closes my current shell!? And even more strangely, if that last sleep line is commented out, it can run backgrounded quite happily. Can anyone explain? I understand that it's to do with the `-m` (job control) option to `set` but I don't understand why...

I can see that happen if the script is run with Bash 4.3.30, but not with Bash 4.4.12. (The version of the shell running the script doesn't seem to matter that much.)

I didn't bisect that any further, but there's this in the changelog that looks like it might apply:


This document details the changes between this version, bash-4.4-rc1, and
the previous version, bash-4.4-beta.

i. Fixed a bug that caused background processes run from non-interactive shells
with job control enabled to place the terminal in the wrong process group
under certain circumstances.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 43145b9d4c0172afc73eee7ab9a23e4b