How to Execute After Read?

johnywhy

New Member
Joined
Aug 4, 2019
Messages
7
Reaction score
3
Credits
0
In zsh, If i press enter before the read is finished, then the last echo command gets executed. Great!

Code:
read -t 10 && echo 'bye'

But, if i DON'T press enter, then the final echo does NOT get executed.

How can i ensure the final echo gets executed if i allow the read to finish?

thx
 
Last edited:


OP
J

johnywhy

New Member
Joined
Aug 4, 2019
Messages
7
Reaction score
3
Credits
0
Update, some progress:
Read may behave a bit differently in zsh.

But this doesn't work either:
Code:
bash -c "read -t 5 && echo 'bye'"
 

atanere

Well-Known Member
Joined
Apr 6, 2017
Messages
2,645
Reaction score
2,792
Credits
145
Nice work!

Welcome to the site!
 
OP
J

johnywhy

New Member
Joined
Aug 4, 2019
Messages
7
Reaction score
3
Credits
0
Thx! i love this trick with read. Can't do this with sleep. Only way is with a loop :)
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Top