我看到了here bash 4.4 会查找变量 $INSIDE_EMACS
来确定它是否在 comint 模式缓冲区中运行。但是我似乎找不到这对 bash 行为有何改变。 $INSIDE_EMACS
进行了哪些更改?
最佳答案
根据emacs doc :
Emacs sets the environment variable
INSIDE_EMACS
in the subshell toversion,comint
, where version is the Emacs version (e.g.,24.1
). Programs can check this variable to determine whether they are running inside an Emacs subshell.
查看了 bash 的 source code并且没有什么魔力:
575 /*
576 * M-x term -> TERM=eterm-color INSIDE_EMACS='251,term:0.96' (eterm)
577 * M-x shell -> TERM='dumb' INSIDE_EMACS='25.1,comint' (no line editing)
578 *
579 * Older versions of Emacs may set EMACS to 't' or to something like
580 * '22.1 (term:0.96)' instead of (or in addition to) setting INSIDE_EMACS.
581 * They may set TERM to 'eterm' instead of 'eterm-color'. They may have
582 * a now-obsolete command that sets neither EMACS nor INSIDE_EMACS:
583 * M-x terminal -> TERM='emacs-em7955' (line editing)
584 */
585 if (interactive_shell)
586 {
587 char *term, *emacs, *inside_emacs;;
588 int emacs_term, in_emacs;
589
590 term = get_string_value ("TERM");
591 emacs = get_string_value ("EMACS");
592 inside_emacs = get_string_value ("INSIDE_EMACS");
593
594 if (inside_emacs)
595 {
596 emacs_term = strstr (inside_emacs, ",term:") != 0;
597 in_emacs = 1;
598 }
599 else if (emacs)
600 {
601 /* Infer whether we are in an older Emacs. */
602 emacs_term = strstr (emacs, " (term:") != 0;
603 in_emacs = emacs_term || STREQ (emacs, "t");
604 }
605 else
606 in_emacs = emacs_term = 0;
607
608 /* Not sure any emacs terminal emulator sets TERM=emacs any more */
609 no_line_editing |= STREQ (term, "emacs");
610 no_line_editing |= in_emacs && STREQ (term, "dumb");
611
612 /* running_under_emacs == 2 for `eterm' */
613 running_under_emacs = in_emacs || STREQN (term, "emacs", 5);
614 running_under_emacs += emacs_term && STREQN (term, "eterm", 5);
615
616 if (running_under_emacs)
617 gnu_error_format = 1;
618 }
更新:
刚刚找到 bash 处理 INSIDE_EMACS
的原始请求(在 bug-bash 邮件列表中):Bash should look at INSIDE_EMACS not just EMACS
关于bash - $INSIDE_EMACS 对 bash 有什么作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47062370/