-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running :!program
from VimEnter
sends input to the program
#8591
Comments
**Describe the bug**
Executing a command with `:!` from VimEnter auto-command sends input to that process.
**To Reproduce**
Make your `.vimrc` look like this:
```vim
au VimEnter * !cat > wtf
```
And just start `vim` (use <kbd>Ctrl+D</kbd> to finish `cat`).
You'll see output like this:
```
^[[2;2R^[[3;1R^[[>41;367;0c^[]10;rgb:ffff/ffff/ffff^G^[]11;rgb:0808/0808/0808^G
```
and `wtf` file in current directory containing the same:
```
00000000 1b 5b 32 3b 32 52 1b 5b 33 3b 31 52 1b 5b 3e 34 |.[2;2R.[3;1R.[>4|
00000010 31 3b 33 36 37 3b 30 63 1b 5d 31 30 3b 72 67 62 |1;367;0c.]10;rgb|
00000020 3a 66 66 66 66 2f 66 66 66 66 2f 66 66 66 66 07 |:ffff/ffff/ffff.|
00000030 1b 5d 31 31 3b 72 67 62 3a 30 38 30 38 2f 30 38 |.]11;rgb:0808/08|
00000040 30 38 2f 30 38 30 38 07 3a |08/0808.:|
00000049
```
**Expected behavior**
No unexpected output on the screen and empty `wtf` file.
**Environment (please complete the following information):**
- Vim version: 8.2.2876
- OS: Slackware 14.2
- Terminal: xterm
**Additional context**
This looks a lot like control sequences, although I'm not sure whether
they are coming from Vim itself or that's a terminal responding to
some query from Vim. I suspect the latter.
Yes, Vim request status from the terminal, and since there is no side
channel these are mixed with keyboard input.
Vim does try to read the escape codes before starting the program, but
this is timing sensitive.
A simple way would be to not invoke the program directly from VimEnter,
but using a timer to run it a tiny bit later.
Hmm, perhaps we could have an autocommand event that is triggered when
the codes that are expected have been received. Problem is though that
some requests may be unanswered, and then it would never trigger.
…--
hundred-and-one symptoms of being an internet addict:
182. You may not know what is happening in the world, but you know
every bit of net-gossip there is.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
On 2021-07-19, Bram Moolenaar wrote:
A simple way would be to not invoke the program directly from VimEnter,
but using a timer to run it a tiny bit later.
Hmm, perhaps we could have an autocommand event that is triggered when
the codes that are expected have been received. Problem is though that
some requests may be unanswered, and then it would never trigger.
You could use a timeout to fix that. A few seconds should be
sufficient. If a user's terminal never responds and the user gets
tired of waiting that long, then they don't need the autocommand
anyway.
The timeout should be settable, and there should be a way to
determine whether the autocommand was triggered by the terminal
responses or by the timer expiring. Some v: variable, perhaps.
Maybe just check for the presence of all the expected responses.
Regards,
Gary
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Executing a command with
:!
from VimEnter auto-command sends input to that process.To Reproduce
Make your
.vimrc
look like this:And just start
vim
(use Ctrl+D to finishcat
).You'll see output like this:
and
wtf
file in current directory containing the same:Expected behavior
No unexpected output on the screen and empty
wtf
file.Environment (please complete the following information):
Additional context
This looks a lot like control sequences, although I'm not sure whether they are coming from Vim itself or that's a terminal responding to some query from Vim. I suspect the latter.
The text was updated successfully, but these errors were encountered: