How to return to bash prompt after printing output from backgrounded function?
问题 How can I return to my bash prompt automatically after printing output from a function that was put in the background? For example, when I run the following script in a bash shell: fn(){ sleep 10 echo "Done" exit } fn & After running the script, it immediately returns my prompt. After 10 seconds, it prints "Done" and then displays a blinking cursor on a new line: $ Done ▏ The script isn't running anymore, but I don't get my prompt back until I press Return . Is there any way to force a return