bash:如何执行函数而不是同名命令

FSM*_*axB 2 linux bash command function

我即将学习bash脚本并编写一个这样的小脚本用于测试目的:

#!/bin/bash
function time {
    echo $(date)
}

time
Run Code Online (Sandbox Code Playgroud)

However the function doesn't get executed, instead the command time is running.

So what do I have to do to execute the function instead?

I'm running bash 4.2.45

kon*_*box 9

要运行与特殊关键字同名的函数time,请引用它,例如:

function time {
    echo "$(date)"
}

'time'
Run Code Online (Sandbox Code Playgroud)