Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14524

Re: Add sleep builtin

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Add sleep builtin
Date 2018-08-22 08:22 -0400
Message-ID <mailman.5403.1534940541.1292.bug-bash@gnu.org> (permalink)
References <CAJnmqwZ1GUZRtGRHt8xy_-tdTjVsAQKt-toGAEn5e9gjFrR0vQ@mail.gmail.com> <83513822-23BF-4695-9542-F967512A8A3D@gmail.com> <5B7CB832.4080004@tlinx.org>

Show all headers | View raw


On Tue, Aug 21, 2018 at 06:11:14PM -0700, L A Walsh wrote:
> sleep .001 (ms sleep)...not practical if loaded each time)
> I often use sleep .1/.3/.5 ... if the builtin doesn't support sleep times
> < 1 second, then it's probably not worth it.
> 
> Also, needs to actually sleep for the listed time.

Just for the record, the POSIX sleep command only accepts an "integral
number of seconds specified by the time operand."  Sub-second sleep(1)
is a GNUism.

That said, ksh's builtin sleep accepts "decimal seconds or fractions of
a second", so there is precedent going that way... then again, ksh also
has floating point math *in general*, whereas bash does not.  Adding
floating-point support to bash's builtin sleep without adding it to
bash's arithmetic expressions might seem odd.

> I  remember some implementations only wait till the clock reaches the
> new time in seconds -- meaning that the actual sleep time could be
> .001 seconds.

If true, that would actually violate POSIX.  The sleep time must be
"at least" as long as the operand.  It may be longer, but never shorter.

You might be remembering it wrong.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Add sleep builtin Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-22 08:22 -0400

csiph-web