In a shell script, if I source even a trivial vim script this way
$ cat ascript
:q
$ cat test
vim -S ascript -N -u NONE
read
This is what I get when I run it:
$ bash test
^[[I
The ^[[I output is unexpected and breaks the further logic of my shell script.
Does anyone guess/know the nature of it and a possible way to eliminate that effect?
upd1
zsh test output is the same, sh does not work for other reason.
$ zsh test
^[[I
$ sh test
test: 2: read: arg count
And just for completeness:
"Debian GNU/Linux 11 (bullseye)"
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 01 2021 01:51:08)
upd2
After trying to reproduce on other systems:
A shorter way is
vim -c ': quit' ; read
which may or may not provide you with some garbage output, ^[[I is just one of the examples, another possible is ^[[2;2R^[]11;rgb:3838/3b3b/4040^G. So the other fact I figured out, the issue is not there if one works in a tmux session.
That made me think towards the matter of vim (mis?)handling the terminal settings.
And indeed changing TERM from default xterm-256color to screen-256color makes the issue resolved, or rather worked around.
To resolve it right way, one probably should find a proper combination of terminal-options.
sh testorzsh test?vim? There may be a better tool for noninteractive use:browse oldbut not interactively, using vim'sredir. This is actually done long time ago and works fine excluding for cases like in this question.