Porting list.c and list.h from southernbear/rtenv
Check read return value in case of read error in shell