为什么我会收到这些错误 - 在寻找匹配的 `)' 时出现意外的 EOF

Why I'm getting these Errors - unexpected EOF while looking for matching `)'

代码

 #! /bin/bash
    read -p "INterest " interest
    read -p "Enter loan " loan

    tot(){
        total=$( bc -l <<EOF
            scale=3
            $loan + $interest^3
            EOF
    )
        echo "$total"
    }

    tot

输出 利息 12 输入贷款 12 ./eofp.sh: 第 6 行:寻找匹配的 `)' 时出现意外的 EOF ./eofp.sh:第 15 行:语法错误:文件意外结束

您的 here document 被错误终止;或者

  1. 此处文档以 <<-EOF 使用制表符或
  2. 缩进开始
  3. EOF 放在没有任何其他字符的行上。