Jon Deaton
Jon Deaton

Reputation: 4379

Why does sleep 1 | vim file break shell?

While testing piping on a shell that I wrote, I noticed that the command

sleep 1 | vim file

causes text written to stdout to be misaligned in subsequent commands. At first I thought that this was a bug in my shell but then I noticed that it has the same effect in other shells like bash and zsh. Why does this happen?

Upvotes: 2

Views: 189

Answers (1)

Tinmarino
Tinmarino

Reputation: 4041

Vim needs a interactive stdin (from shell).

sleep 3; vim file  

If you dont need the input or:

vim <(sleep 3; ls)
vim -d <(ls) <(ls -a)

If you need it. Warning: no space between < and (

See more there: https://askubuntu.com/a/510907/360110

Upvotes: 1

Related Questions