Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: time for loop



On Mon, 2018-12-03 at 10:05 -0600, Peng Yu wrote:
> time for ((i=0;i<1000;++i))
> do
>     :
> done
> 
> The zsh manual says it only support pipeline.

Actually, that's another piece of documentation that's not really
accurate.  The code is parsed fine, but the implementation of "time"
internally only works if the code being timed was run in a separate
process.

Compare the syntactically very similar

time ( print foo )

and

time { print foo }

You get a time only with the first one.

As zsh has been around for over 25 years now, you'll realise that
limitations like this aren't going to change (unless you decide to look
at it yourself, please feel free!), and nor is the basic syntax outside
compatibility mode.

pws




Messages sorted by: Reverse Date, Date, Thread, Author