Why command `vim -T dumb -c 'echo "Hello World!"' -c q` behaves differently when /dev/stdin is redirected from when /dev/stdin is not redirected?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why command `vim -T dumb -c 'echo "Hello World!"' -c q` behaves differently when /dev/stdin is redirected from when /dev/stdin is not redirected?

Peng Yu
Hi,

The following code runs well.

vim -T dumb -c 'echo "Hello World!"' -c q

~$ cat main.sh
#!/usr/bin/env bash

cat < /dev/stdin > /dev/null
vim -T dumb -c 'echo "Hello World!"' -c q

But running the following command will show "Vim: Warning: Input is
not from a terminal". The problem is related with /dev/stdin. Does any
know how to understand this behavior of vim? Thanks.

~$ ./main.sh <<< xxxx

--
Regards,
Peng

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Why command `vim -T dumb -c 'echo "Hello World!"' -c q` behaves differently when /dev/stdin is redirected from when /dev/stdin is not redirected?

Christian Brabandt
Am 2015-04-20 03:58, schrieb Peng Yu:

> vim -T dumb -c 'echo "Hello World!"' -c q
>
> ~$ cat main.sh
> #!/usr/bin/env bash
>
> cat < /dev/stdin > /dev/null
> vim -T dumb -c 'echo "Hello World!"' -c q
>
> But running the following command will show "Vim: Warning: Input is
> not from a terminal". The problem is related with /dev/stdin. Does any
> know how to understand this behavior of vim? Thanks.

You mean, why the warning is printed? The warning just means that
/dev/stdin
is (most likely) redirected. That is useful to know,
since it means, you can't type commands to control Vim.

Or is there actually a different behaviour depending on whether
stdin is redirected?

Best,
Christian

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Why command `vim -T dumb -c 'echo "Hello World!"' -c q` behaves differently when /dev/stdin is redirected from when /dev/stdin is not redirected?

Gary Johnson-4
In reply to this post by Peng Yu
On 2015-04-19, Peng Yu wrote:

> Hi,
>
> The following code runs well.
>
> vim -T dumb -c 'echo "Hello World!"' -c q
>
> ~$ cat main.sh
> #!/usr/bin/env bash
>
> cat < /dev/stdin > /dev/null
> vim -T dumb -c 'echo "Hello World!"' -c q
>
> But running the following command will show "Vim: Warning: Input is
> not from a terminal". The problem is related with /dev/stdin. Does any
> know how to understand this behavior of vim? Thanks.
>
> ~$ ./main.sh <<< xxxx

You are redirecting the script's stdin from the here string xxxx, so
that is the stdin that vim sees, which is not a terminal.

If you want vim's stdin to come from the terminal, either don't
redirect the script's stdin, or redirect vim's stdin from /dev/tty,
e.g.

    vim -T dumb -c 'echo "Hello World!"' -c q < /dev/tty

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.