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...
GNU bash, version 4.4.23(1)-release (x86_64-apple-darwin17.5.0)GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)