bash“&"无需打印"[1] +完成" [英] bash "&" without printing "[1]+ Done "

查看:46
本文介绍了bash“&"无需打印"[1] +完成"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.bashrc中调用一个脚本来打印打开终端时收到的新消息的数量,我希望该调用在访问网络时不阻塞,有时要花几秒钟,这意味着我不能使用终端,直到完成.

I call a script in my .bashrc to print number of new messages I have when I open the terminal, I want the call to be non blocking as it accesses the network and sometimes takes a few seconds which means I can't use the terminal until it completes.

但是,如果我放:

    mailcheck & 

在我的bashrc中,

可以正常工作.但随后打印出一个空行,当我按Enter键时,我得到了它并打印

in my bashrc, it works fine. but then prints an empty line and I have when I press enter and it prints

    [1]+  Done                    ~/bin/mailcheck

这很麻烦,有办法解决吗?

This is very messy is there a way around this?

推荐答案

该消息不是来自mailcheck,而是来自bash的工作控制,告诉您有关背景工作的信息.避免这种情况的方法是告诉bash您不希望它由作业控制来管理:

That message isn't coming from mailcheck, it's from bash's job control telling you about your backgrounded job. The way to avoid it is to tell bash you don't want it managed by job control:

mailcheck &
disown $!

这篇关于bash“&"无需打印"[1] +完成"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆