[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to set the terminal to vim?
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] How to set the terminal to vim? |
Date: |
Wed, 3 Jun 2015 10:29:47 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Jun 03, 2015 at 09:23:12AM -0500, Peng Yu wrote:
> I see the following warning. It is because the bash script takes the
> stdin. Does anybody know how to make vim get back the stdin? Thanks.
> $ ./main.sh </dev/null
> Vim: Warning: Input is not from a terminal
Well, the obvious first step would be not redirecting stdin from /dev/null.
It's kinda hard to get useful data from there.
> $ cat main.sh
> #!/usr/bin/env bash
>
> while read -r -d $'\n' line
> do
> echo "$line"
> done
> vim main.sh
What is this supposed to do? You have a loop that reads stdin until
EOF, and then you have another process that wants to read the same stdin
after EOF.
Did you want vim to read from the user's terminal instead of script's stdin?
If that's the case, then:
vim main.sh </dev/tty
It would help if you would SAY what you are doing, instead of always
making people guess. There's plenty of room left in the email for
a description of the problem.
By the way, read -d $'\n' is redundant. That's just the same as read.