Date:        Tue, 18 Feb 2020 14:50:50 +0100
    From:        Joerg Schilling <joerg.schill...@fokus.fraunhofer.de>
    Message-ID:  <5e4bebba.XCR/ahv7oqvibm+7%joerg.schill...@fokus.fraunhofer.de>

  | If you like to get the previous POSIX behavior, call:
  |
  |     time -p some-command
  |
  | This is what POSIX did require in the past...

No, it didn't, the -p is needed only to get the POSIX specific
output format.

  | When you do that, you of course cannot time functions or builtins.

Not directly, one can time a script that runs the function/builtin
and subtract the time for running an empty script, but that is kind
of complex.    Why someone would want to time a builtin I'm not sure
(with the possible exception of elapsed time of wait)

  | There however is a shell that has massive problems: "zsh".
  |
  | zsh cannot time functins or builtins at all and even more:
  |
  |     time -p sleep 1
  |     zsh: command not found: -p
  |
  | as you see, the command line documentd by POSIX does not work.

But
        time sleep 1
works in it just fine...

zsh $ time sleep 1
sleep 1  0.00s user 0.00s system 0% cpu 1.004 total

The output format isn't POSIX standard, but the data is there.

Further:

zsh $ \time -p sleep 1
real         1.00
user         0.00
sys          0.00
zsh $ command time -p sleep 1
real         1.00
user         0.00
sys          0.00

also both work, so it isn't quite as hopeless as it seems.  Both of
those suppress the reserved word processing, and I guess I really
should have used

zsh $ \command time -p sleep 1
real         1.00
user         0.00
sys          0.00

just in case "command" has been turned into a reserved word as well
(since apparently that's possible, and entirely POSIX compatible).

kre


Reply via email to