if ステートメントが機能しない理由がわかりません。$EmployeeType が Commission または Hourly の場合でも、Weekly Salary を入力するよう求められます。elif の代わりにすべてに対して if ステートメントを使用する必要がありますか? すべてのifステートメントを使用してみましたが、「予期しないトークンに近い構文エラー "}"」というエラーが発生し続けます。アドバイスよろしくお願いします。
出力:
Enter Payroll of an employee
Enter employee name: Mary
Mary is Hourly employee.
Enter Weekly Salary :
payroll_employee()
{
echo
echo "[Option: $input]"
echo "Enter Payroll of an employee "
echo
echo -en "Enter employee name: "
read Name
#Retrieve current entry into individual fields
line=`grep -i "$Name" $PAYROLL`
Name=`echo $line | cut -d "," -f1`
EmployeeID=`echo $line | cut -d "," -f2`
EmployeeHP=`echo $line | cut -d "," -f3`
EmployeeType=`echo $line | cut -d "," -f4`
#Check if entry exist in records
if [ `count_lines "^${Name},"` -eq 0 ]
then
echo "Error: This particular record does not exist!!"
else
echo "$Name is ${EmployeeType} employee."
if [ "$EmployeeType"="Salaried" ]
then
echo $EmployeeType
echo -en "Enter Weekly Salary :"
read wsalary
echo
elif ["$EmployeeType"="Hourly" ]
then
echo -en "Enter hourly wage:"
read hsalary
echo -en "Enter hours worked this week:"
read hours
let "hwages = hsalary * hours"
echo -en "Gross wages: \$$hwages"
echo
elif ["$EmployeeType"="Commission" ]
then
echo -en "Enter Weekly Total Sales:"
read csales
echo -en "Gross wages:"
read cwages
echo
fi
fi
echo -en "Hit [Enter] to return to main menu..."
read
}