几天前,我在 Ubuntu 12.10 64 位机器上安装了 ZSH(和 Oh-My-ZSH)。我只是试图做:
time (time ls)
Run Code Online (Sandbox Code Playgroud)
并收到此错误:
zsh: command not found: time
( time ls; ) 0.00s user 0.00s system 64% cpu 0.002 total
Run Code Online (Sandbox Code Playgroud)
完全相同的事情在我的 Mac 上的 ZSH 上工作。
我也尝试运行 ZSH 而不加载任何配置文件,使用zsh -f -d
,但得到了同样的错误。
这里可能有什么问题?
一些可能有帮助的输出:
? ~ type -a time
time is a reserved word
? ~ time (type -a time)
time is a reserved word
( type -a time; ) 0.00s user 0.00s system 0% cpu 0.001 total
? ~ time (time)
zsh: command not found: time
( time; ) 0.00s user 0.00s system 0% cpu 0.001 total
? ~ which time
time: shell reserved word
? ~ time (which time)
time: shell reserved word
( which time; ) 0.00s user 0.00s system 0% cpu 0.001 total
Run Code Online (Sandbox Code Playgroud)
time
是 zsh 中的保留字。它仅在命令的开头被识别。它是一个保留字,而不是一个内置字,因为当你写的时候time foo
| bar
,是复合命令foo | bar
被计时,而不仅仅是foo
.
wheretime
不被识别为保留字,它被解释为外部命令的名称。无论出于何种原因,您的系统都没有time
安装任何命令。所以命令喜欢\time
,=time
或者第二个time
在time time
尝试调用不存在的time
可执行文件,你会得到错误信息“找不到命令:时间”。
如果您希望能够运行time (time ls)
(不是说这是一个有用的命令),请安装该time
软件包。它是 的依赖项ubuntu-standard
,这表明您应该安装它。