Why multiple case judgment effect.


while echo -n "input your name:"
( ( read -t 5 name ) && ( [ -z "$name" ] || [ $name != 'exit' ] )); do
echo hello :$name ,exit please input exit !
done




When I enter the name $name is empty

Started by Abbott at January 01, 2017 - 6:45 AM

while echo -n "input your name:"; do
read -t 5 name
[ -z "$name" -o "$name" != "exit" ] && echo "hello :$name ,exit please input exit !" || exit
done

Posted by Bernard at January 07, 2017 - 8:33 AM

while echo -n "input your name:"; do
read -t 5 name
if [ -z "$name" -o "$name" != "exit" ]; then
echo "hello :$name ,exit please input exit !"
else
exit
fi
done

Posted by Bernard at January 11, 2017 - 7:39 AM