为什么zsh-time对某些命令不起作用,而bash-time可以?
为什么Zsh为什么zsh-time对某些命令不起作用,而bash-time可以?,time,zsh,oh-my-zsh,Time,Zsh,Oh My Zsh,为什么Zshtime对某些命令不起作用 ➜ ~ type time time is a reserved word ➜ ~ time sleep 1 sleep 1 0.00s user 0.00s system 0% cpu 1.004 total # not work for echo ➜ ~ time echo hello hello # not work with for ➜ ~ time for i in {1..3}; do curl -s http://baidu.co
time
对某些命令不起作用
➜ ~ type time
time is a reserved word
➜ ~ time sleep 1
sleep 1 0.00s user 0.00s system 0% cpu 1.004 total
# not work for echo
➜ ~ time echo hello
hello
# not work with for
➜ ~ time for i in {1..3}; do curl -s http://baidu.com > /dev/null; done
但如果对bash的更改同时得到支持
➜ ~ exec bash
bash-3.2$ type time
time is a shell keyword
$ time echo hello
hello
real 0m0.000s
user 0m0.000s
sys 0m0.000s
bash-3.2$ time for i in {1..3}; do curl -s http://baidu.com > /dev/null; done
real 0m0.099s
user 0m0.019s
sys 0m0.018s
我认为应该在@zhugoowei上问这个问题:只是一个猜测(因为手册页没有告诉我这方面的任何信息):
zsh
time命令似乎只在需要创建子进程时才写入时间统计信息。因此,time sleep
起作用,time(echo hello)
也起作用。例如,如果foo
是一个函数,time foo
不会在zsh中输出定时信息,但如果foo
是一个外部命令,则会输出定时信息。