How to return to bash prompt after printing output from backgrounded function?

后端 未结 3 535
清酒与你
清酒与你 2020-12-24 15:20

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 i

3条回答
  •  星月不相逢
    2020-12-24 15:52

    What is the problem you're trying to solve?

    Right now, this is more or less a cosmetic problem. You're still in the shell, and the prompt is still there. Just type another command and it will be executed.

    Alternatively, run the function in the foreground, or if you need to do something else in between, use wait:

    $ fn & pid=$!
    $ : something else
    $ wait ${pid}
    

提交回复
热议问题