0

Env: Windows 11 pro.

I want to call msys2 bash in git-bash's vim where both shares the same version of vim and bash (although this context seems to be weird).

I asked one origin question in Vi/Vim SE and the problem seems to be failure to have set -m option when calling :call term_start("/d/msys64/usr/bin/bash -li -vx") (-l is to source .bash_profile, etc. -i is to ensure we can use bash in vim) in vim. It shows hivxBH for $-. But for one normal bash called by :call term_start("bash -li -vx"), $- is himvxBH.

I tried to use -lim -vx but that doesn't work.

The above -l works which is checked by shopt -p login_shell at the top of /etc/profile temporarily showing shopt -s login_shell.


When without -m option, we also have the following error msg (I followed this QA. But I have already used -i option and this option fails to add -m option by default) before sourcing /etc/profile

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

The key term is 'job control' which is important for vim to run terminal inside (:h terminal-use says 'A job can be started connected to the terminal emulator')

Since m option corresponds to 'monitor' where 'Job control is enabled' as the manual says, it is the problem source.


This question can be solved indirectly by using msys2 vim to call git-bash so that I can use one vim version to call all shells on my machine including git-bash, pwsh and msys2 bash.

Q:

IMHO, it seems that git-bash's vim doesn't have the permission to call /d/msys64/usr/bin/bash (but git-bash can). Is there one way to solve directly with the above 'Inappropriate ioctl for device' failure which causes 'no job control in this shell'?

Edited:

After being hinted by this blog, 'Inappropriate ioctl for device' seems to be due to using pipe as stdin more specifically. Normally, ls -al /dev/fd/* -al at the top of ~/.bash_profile will output something like /dev/fd/0 -> /dev/pty3 when term_start. But when using the param /d/msys64/usr/bin/bash it will have /dev/fd/0 -> pipe:[0].

Then by seeing this post, it seems to be due to not having the privelege. However msys2 can call git-bash with /dev/fd/0 -> /dev/cons3.

Solved now:

The problem is due to msys2 encapsulated many details and it can't be manipulated by vim but can be manipulated by git-bash.

# git bash try to call msys2 bash
# here although the administrator has the rwx mode, using as one administrator can't solve the problem.
$ ls -al /d/msys64/dev/
total 4
drwxr-xr-x 1 foo 197609 0 Mar 28 16:59 ./
drwxr-xr-x 1 foo 197609 0 Apr  4 16:29 ../
drwxr-xr-x 1 foo 197609 0 Mar 28 16:59 mqueue/
drwxr-xr-x 1 foo 197609 0 Mar 28 16:59 shm/
# msys2 bash try to call git bash
$ ls -al /d/Git/dev/
total 8
drwxr-xr-x 1 foo foo  0 Apr  2 09:53 .
drwxr-xr-x 1 foo foo  0 Apr  2 09:53 ..
lrwxrwxrwx 1 foo foo 13 Apr  2 09:53 fd -> /proc/self/fd
drwxr-xr-x 1 foo foo  0 Apr  2 09:52 mqueue
drwxr-xr-x 1 foo foo  0 Apr  2 09:52 shm
lrwxrwxrwx 1 foo foo 15 Apr  2 09:53 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 foo foo 15 Apr  2 09:53 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 foo foo 15 Apr  2 09:53 stdout -> /proc/self/fd/1

So for one workaround, we can use msys2 as the main terminal because git-bash doesn't encapsulate /dev.


The above messy development env is only one temporary env I used in Windows (really not recommended to use it). Normally, I developed in Archlinux. Here is to show where the problem is. If you have similar problems, hope this can help you.

0

You must log in to answer this question.

Browse other questions tagged .