zsh-users
 help / color / mirror / code / Atom feed
* time for loop
@ 2018-12-03 16:05 ` Peng Yu
  2018-12-03 16:36   ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Yu @ 2018-12-03 16:05 UTC (permalink / raw)
  To: zsh-users

Hi,

The following code print nothing in zsh. But it can print the time in bash.

time for ((i=0;i<1000;++i))
do
    :
done

The zsh manual says it only support pipeline. Is it better to allow it
support for-loop or other groups of code?

-- 
Regards,
Peng

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: time for loop
  2018-12-03 16:05 ` time for loop Peng Yu
@ 2018-12-03 16:36   ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2018-12-03 16:36 UTC (permalink / raw)
  To: zsh-users

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-03 16:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20181203160732epcas4p3be986c9149fc8a51e296c882b5f979e4@epcas4p3.samsung.com>
2018-12-03 16:05 ` time for loop Peng Yu
2018-12-03 16:36   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).