2020-02-18 14:50:50 +0100, Joerg Schilling: [...] > There however is a shell that has massive problems: "zsh".
> zsh cannot time functins or builtins at all Zsh's "time" keyword reports *process* resource usage (for each component of the timed pipeline). If there's no process, there's nothing to report. If you want to time a process running a function, builtin or compound command, you need a subshell: time (...) Note that that resource usage reporting is not only about CPU and elapse time as zsh supports reporting the same things as csh or GNU time does. For things like "The average amount in (shared) text space used in kilobytes" (%X), approaches that substract usage after and before are not really usable. See how tcsh does fork by itself when you try to time builtins. > time -p sleep 1 > zsh: command not found: -p "time" is a keyword in zsh. keywords don't take options. I suppose zsh could add the same ugly kludge as in ksh93 for POSIX compliance in sh mode, but nobody every bothered asking for it it would seem. "time" is a debugging/interactive tool mostly. It's hardly relevant in portable scripts. Which is why I'd tend to agree with kre that it's probably not worth the bother POSIX specifying it. > > as you see, the command line documentd by POSIX does not work. [...] If you did need zsh to interpret a sh script that used "time -p" (not that I've ever come across such a script), you could always do: emulate sh 'disable -r time; . /path/to/that-script' -- Stephane