2020-02-19 11:52:21 +0100, Joerg Schilling:
[...]
> > $ zsh -c 'time -p uname | cat'
> > zsh:1: command not found: -p
> 
> BTW: I remember that you frequently write that zsh intends to emulate the csh 
> behavior, but csh _is_ able to get timing for builtin commands:
> 
> csh
> % time alias
> 0.0u 0.0s 0:00 0% 0+0k 0+0io 0pf+0w
> % 
[...]

Like I said, csh forks there to be able to report the usage:

tcsh> alias a b
tcsh> alias
a       b
tcsh> time alias c d
0.000u 0.000s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
tcsh> alias
a       b

(missing "c      d" in that output as alias c d was run in a
subshell).

zsh does have a csh emulation mode (emulate csh), which makes it
more csh-like, but there's no way it could be twisted into being
a csh interpreter. That's more of a helper mode to make it more
friendly to users who come from tcsh.

Like ksh or bash, zsh got many features from csh. Of the three
shells, it's probably the one which got the most (like it's the
one which got the most features from rc, or more generally the
most features).

Here, when it comes to time, it got the full getrusage() from
csh/BSD, it extended it by timing each pipeline component
separately (very useful to spot bottlenecks).

Like csh, it report *process* resource usage.

Contrary to csh, it supports timing pipelines, compounds,
functions (csh has no functions anyway).

And like I said, contrary to csh, it doesn't implicitly add an
extra fork. That would change the functionality and would not be
practical given the point above.

That does mean it can't report resource usages of things that
are not run in a separate process. That's a sometimes annoying
drawback (though some easy workaround), but that's a tradeoff.

-- 
Stephane

Reply via email to