Vinay Shukla
Vinay Shukla

Reputation: 1844

While executing a shell script I created a .txt file, edited it, after saving the script exits

echo "some content" >file.txt

vim file.txt;

echo " Edited the file successfully" 

echo "Should we proceed with some task (y/n)"

read input </dev/tty

case $input
y ) do some task
n ) exit

What happens is the file opens I am able to edit the file and after saving the file it executes the echo and then exits.

It gives me an error like this before I am able to edit the file.

Vim: Warning: Input is not from a terminal

Upvotes: 1

Views: 141

Answers (1)

Barmar
Barmar

Reputation: 780673

If your input is redirected, use:

vim file.txt </dev/tty

to redirect back to the terminal while running vim.

Upvotes: 2

Related Questions