如何告诉bash不要发出警告“不能设置终端进程组"?和“此外壳中无作业控制";什么时候不能主张工作控制权? [英] How to tell bash not to issue warnings "cannot set terminal process group" and "no job control in this shell" when it can't assert job control?

查看:108
本文介绍了如何告诉bash不要发出警告“不能设置终端进程组"?和“此外壳中无作业控制";什么时候不能主张工作控制权?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要创建一个新的交互式bash shell,请调用 bash -i .由于我的环境问题,bash无法断言作业控制(我在GNU emacs中使用cygwin bash)并发出警告(无法在此shell中设置终端进程组"和无作业控制").-在我的环境中,我必须忍受残障的工作控制,但是我想摆脱警告:

To create a new interactive bash shell I call bash -i. Due to issues with my environment, bash cannot assert job control (I'm using cygwin bash in GNU emacs) and issues warnings ("cannot set terminal process group" and "no job control in this shell"). - I have to live with the disabled job control in my environment, but I would like to get rid of the warning:

我如何告诉bash不要断言作业控制和不发出这些警告?我显然仍然希望将外壳作为交互式外壳.

How can I tell bash not to assert job control and not to issue these warnings? I obviously still want the shell as an interactive one.

注意:我在 .bashrc 中尝试了 set -m ,但是bash在启动时仍会写出警告-〜/.bashrc 后执行code>文件.有可以使用的命令行选项吗?

Note: I have tried set -m in .bashrc, but bash still writes out the warnings on start up - the ~/.bashrc file might be executed after the shell tries to assert job control. Is there a command line option which would work?

推荐答案

man bash 说到 set 选项,这些选项也可以指定为.注意,您将需要 + m 而不是 -m .诚然,手册对此并不十分清楚.

man bash says about set options that The options can also be specified as arguments to an invocation of the shell. Note you will need +m not -m. Admittedly the manual isn't quite clear on that.

但是,在查看 bash 源代码(4.2版)时,显然它会忽略此标志的状态.我会说这是一个错误.

However looking at bash source code (version 4.2), apparently it ignores the state of this flag. I would say this is a bug.

应用以下小补丁可使 bash 在启动时遵守 m 标志.不幸的是,这意味着您将不得不重新编译 bash .

Applying the following small patch makes bash honor the m flag on startup. Unfortunately this means you will have to recompile bash.

--- jobs.c.orig 2011-01-07 16:59:29.000000000 +0100
+++ jobs.c      2012-11-09 03:34:49.682918771 +0100
@@ -3611,7 +3611,7 @@
     }

   /* We can only have job control if we are interactive. */
-  if (interactive == 0)
+  if (interactive == 0 || !job_control)
     {
       job_control = 0;
       original_pgrp = NO_PID;

在默认情况下可以进行作业控制的linux机器上进行了测试,因此在mingw上看到的错误消息未在此处打印.不过,您仍然可以看到bash现在尊重 + m .

Tested on my linux machine where job control is available by default, so the error messages you see on mingw are not printed here. You can still see that bash honors the +m now, though.

$ ./bash --noprofile --norc
$ echo $-
himBH
$ fg
bash: fg: current: no such job
$ exit
$ ./bash --noprofile --norc +m
$ echo $-
hiBH
$ fg
bash: fg: no job control

这篇关于如何告诉bash不要发出警告“不能设置终端进程组"?和“此外壳中无作业控制";什么时候不能主张工作控制权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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