Discussion:
Whether line editing disabled, to prevent "bash: bind: warning: line editing not enabled"
(too old to reply)
R. Diez
2018-07-16 08:03:42 UTC
Permalink
Hi there:

I recently switched from configuring Readline in .inputrc to "bind"
commands in a file included from .bashrc . I find it more convenient,
because I can check in a single Bash configuration script into my
personal Git repository and use it in all my computers. Upgrading or
diff'ing it is faster. My personal config file is here:

https://github.com/rdiez/Tools/blob/master/Bash/bashrc-rdiez.sh

However, after the switch, I am getting this warning:

bash: bind: warning: line editing not enabled

This happens only in Emacs 'shell' windows, and not on Emacs 'term'
windows or on other terminal emulators.

I saw that Bash turns line editing off when it sees an EMACS environment
variable. That variable is not present on my setup, and other people
report the same:

https://stackoverflow.com/questions/41046558/bashrc-how-to-check-in-what-terminal-the-shell-is-running

On a 'shell' Emacs window, this is what I get:

declare -x INSIDE_EMACS="26.1,comint"
declare -x TERM="dumb"
declare -x TERMCAP=""

On a 'term' Emacs window:

declare -x INSIDE_EMACS="26.1,term:0.96"
declare -x TERM="eterm-color"
declare -x
TERMCAP="eterm-color:li#62:co#206:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%i%d;%dH:nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt:al=\\E[L:dl=\\E[M:DL=\\E[%dM:AL=\\E[%dL:cs=\\E[%i%d;%dr:sf=^J:dc=\\E[P:DC=
\\E[%dP:IC=\\E[%d@:im=\\E[4h:ei=\\E[4l:mi::so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m:UP=\\E[%dA:DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E
[5~:@7=\\E[4~:kh=\\E[1~:mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%dm:AF=\\E[3%dm:cr=^M:bl=^G:do=^J:le=^H:ta=^I:se=\\E[27m:ue=\\E[24m:kb=^?:kD=^[[3~:sc=\\E7:rc=\\E8:r1=\\Ec:"

declare -x TERMINFO="/home/rdiez/emacs-26.1-bin/share/emacs/26.1/etc/"


In both cases, Bash is interactive, which means that [ -t 1 ] returns true.

I am guessing that Bash turns off line editing based on the TERM
variable, but that is not documented (as far as I can see).

Is there a way to find out whether line editing is disabled, so that my
script should skip all the 'bind' commands for Readline?

Thanks in advance,
rdiez
Chet Ramey
2018-07-16 13:18:58 UTC
Permalink
Post by R. Diez
I recently switched from configuring Readline in .inputrc to "bind"
commands in a file included from .bashrc . I find it more convenient,
because I can check in a single Bash configuration script into my personal
Git repository and use it in all my computers. Upgrading or diff'ing it is
https://github.com/rdiez/Tools/blob/master/Bash/bashrc-rdiez.sh
bash: bind: warning: line editing not enabled
This happens only in Emacs 'shell' windows, and not on Emacs 'term' windows
or on other terminal emulators.
I saw that Bash turns line editing off when it sees an EMACS environment
variable. That variable is not present on my setup, and other people report
Bash has used the INSIDE_EMACS variable to determine whether or not it's
running inside an emacs shell window since April, 2015, in response to

http://lists.gnu.org/archive/html/bug-bash/2015-03/msg00179.html

That came after bash-4.3 was released. There was another fix a year later
during the bash-4.4 release cycle to handle future emacs changes.

http://lists.gnu.org/archive/html/bug-bash/2016-04/msg00005.html

Eventually, I will remove the special handling of EMACS and just check
for INSIDE_EMACS. This is how the emacs documentation says to do it going
forward. It should be documented better in the bash documentation.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
R. Diez
2018-07-16 13:36:07 UTC
Permalink
First of all, many thanks for your quick answer.
Post by Chet Ramey
Eventually, I will remove the special handling of EMACS and just check
for INSIDE_EMACS. This is how the emacs documentation says to do it going
forward. It should be documented better in the bash documentation.
It looks like I will have to duplicate Bash' handling of INSIDE_EMACS in
my shell script in order to prevent the warning from appearing. The
logic is not quite straightforward and can change in the future.

May I suggest that Bash provides a way of detecting whether line editing
is active? I mean a way for a shell script to check the result stored in
variable no_line_editing.

Regards,
rdiez
Chet Ramey
2018-07-16 18:16:44 UTC
Permalink
May I suggest that Bash provides a way of detecting whether line editing is
active? I mean a way for a shell script to check the result stored in
variable no_line_editing.
You can already check whether `vi' or `emacs' is enabled. If neither is
enabled, line editing is not enabled.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Loading...