Neovim 中的 Bash 脚本 运行 忽略 "read" 命令

Bash script running in Neovim ignores "read" command

考虑以下 Bash 脚本:

#!/usr/bin/env bash
read -rp "> " INPUT
echo "Your input is: $INPUT"
echo "Done"

当我以常规 Vim 和 运行 :!bash % 打开此文件时,我得到了预期的结果:

> test

Your input is: test

Done

Press ENTER or type command to continue

然而,在 Neovim 中,运行ning 相同的 :!bash % 命令似乎忽略了 read 行:

Your input is:

Done

Press ENTER or type command to continue

我 运行宁 Vim 版本 8.2.500,Neovim 版本 v0.4.3

从命令行执行脚本工作正常,到目前为止我只有在 运行在 Neovim 中使用它时才会遇到这个问题。

我错过了什么?

来自 :! 命令的手动输入:

The command runs in a non-interactive shell connected to a pipe (not a terminal). Use |:terminal| to run an interactive shell connected to a terminal.

当它运行时bash,它的标准输入连接到一个管道,而不是终端,所以你不能使用终端来响应提示。

所以试试

!te bash %s