How to suppress "Input is not from a terminal" message?

已查看 367 次
跳至第一个未读帖子

Igor

未读,
2021年9月24日 03:36:502021/9/24
收件人 vim_use
Hi,
I would like to embed vim code inside bash script.

I have simple text file text_file.txt with content:
aaa

Content sample.sh file:
#!/bin/bash
echo "Start running vim commands inside bash program."
vim +"so dummy.vim" << EOF
   :e text_file.txt
   :s/a/b/
   :x
EOF
echo "End of running run vim commands inside bash program."


Above code opens text_file.txt, replaces letter a with b and saves the file.
When I run sample.sh file from shell: ./sample.sh
The output on terminal is:
Start running vim commands inside bash program.
Vim: Warning: Input is not from a terminal
End of running run vim commands inside bash program.

and script does get executed, so file text_file.txt correctly gets changed to baa
The only little bit annoying thing is the Vim: Warning: Input is not from a terminal message in terminal. How to suppress this message?
Thanks.

Andreas Perstinger

未读,
2021年9月24日 08:58:512021/9/24
收件人 vim...@googlegroups.com
On 24.09.21 09:36, Igor wrote:
> Content sample.sh file:
> #!/bin/bash
> echo "Start running vim commands inside bash program."
> vim +"so dummy.vim" << EOF
> :e text_file.txt
> :s/a/b/
> :x
> EOF
> echo "End of running run vim commands inside bash program."
...
> The only little bit annoying thing is the *Vim: Warning: Input is not from
> a terminal* message in terminal. How to suppress this message?

Start vim in Ex-mode?

vim +"so dummy.vim" -e << EOF

Bye, Andreas

aro...@vex.net

未读,
2021年9月24日 10:21:442021/9/24
收件人 vim...@googlegroups.com
>
> I would like to embed vim code inside bash script.
>

Have you considered using sed, which was designed for this sort of job.
rather than twisting vim inside out?


Tony Mechelynck

未读,
2021年9月25日 09:30:422021/9/25
收件人 vim_use
See :help --not-a-term

Best regards,
Tony.

Igor

未读,
2021年9月26日 13:16:532021/9/26
收件人 vim_use
Thank you very much for your answers.

I changed line from:
vim +"so dummy.vim" << EOF
to line
vim +"so dummy.vim" -e << EOF
and "annoying" message is suppressed, like I wanted.

Just additional question.
Does -e switch has some negative side effect, like some commands not working or working differently like in standard vim?
I am reading about about "Ex mode" (-e switch) and "Improved Ed mode" (-E switch).
回复全部
回复作者
转发
0 个新帖子