echo "Enter the password"
read a
if [ $a == anand ]
then
process_good;;
else
process_bad;;
fi
process_good()
{
echo "Enter the value"
read m
echo "$m"
}
process_bad()
{
echo "Bad password"
}
答案1
要进行调试,请运行脚本并查看哪里失败,然后根据错误进行调整。
您的函数需要在调用之前定义。例如:
function process_good(){
echo "Enter the value"
read m
echo "$m"
}
function process_bad(){
echo "Bad password"
}
echo "Enter the password"
read a
if [ $a == "anand" ]
then
process_good
else
process_bad
fi