4

i'd like to use bash shell from msys2 in emacs and i made the following changes in emacs init file:

(setq explicit-shell-file-name "C:/tools/msys64/usr/bin/bash.exe")
(setq shell-file-name "bash")
(setq explicit-bash.exe-args '("--login" "-i"))
(setenv "SHELL" shell-file-name)
(setenv "BASH_ENV" "~/.bashrc")
(setq shell-command-switch "-c")
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

the shell start and seems work but i got the following error:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

What's the problem?

1 Answer 1

1

When I run M-x shell in Emacs from the package mingw64/mingw-w64-x86_64-emacs it reports warnings:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
tput: unknown terminal "emacs"

The reason is the Bash option -i, which is set by default:

(setq explicit-bash-args (list "-i"))

If you remove it the error disappears:

(setq explicit-bash-args
      (if (eq system-type 'windows-nt)
          (list "--login") ; On Windows -i is wrong!
        (list "-i")))

On Windows bash with -i attempts to configure terminal, but Emacs's shell-mode is not a terminal so ioctl reasonably fails!

2
  • 1
    Without the -i, the shell is non-interactive, and there is no way to have it display command prompts (PS1) in the Emacs shell buffer. Or is there a workaround?
    – Hugues
    Commented Mar 31, 2023 at 23:15
  • 1
    The actual effect of -i is reading the file ~/.bashrc. I suspect PS1 is defined there. It is the reason of missing PS1. I have lots of useful settings in ~/.bashrc so I keep -i and ignore warnings. There are no workarounds.
    – gavenkoa
    Commented Apr 1, 2023 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.