无论输入如何,输出仍然" Dead,ciao in hell" 。
ready: function(){
var leserbriefRef = firebase.database().ref('leserbriefe');
leserbriefRef.on('value', function(snap) {
var n = snap.child('numLeserbriefe').val();
console.log(n);
this.lbriefe = [];
for(var i=0; i<n; i++){
this.push("lbriefe", snap.child('l'+(n - 1 - i)).val());
}
});
}
有人请求帮助我吗?
谢谢!
答案 0 :(得分:2)
你错过了 $ 符号
echo "Which wire to cut? Red or Green? "
read die
if [[ $die = "red" ]]; then
echo "You are saved!"
else echo "Dead,ciao in hell"
fi
<强>输出强>
Which wire to cut? Red or Green?
asd
Dead,ciao in hell
Which wire to cut? Red or Green?
red
You are saved!
答案 1 :(得分:0)
您应该清理用户输入。说,如果他在恐慌中输入reD
怎么办?他还得救了吗?
#!/bin/bash
read -p "Which wire to cut? Red or Green?" die
die="${die:-GREEN}" # if the die's value is null, set it to GREEN
die="${die^^}" # Convert the input to uppercase
if [ "$die" = "RED" ]
then
echo "You are saved!"
elif [ "$die" = "GREEN" ]
then
echo "Dead,ciao in hell"
else
echo "Confused, you deserve to die"
fi
<强>改进强>
read prompt
与-p
选项die
添加了空值检查,并使用die="${die:-GREEN}"
elif-else
部分来处理非预期值的输入。[[..]]
替换[..]
。