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

Re: sleep $floatval



On 2013-09-01 at 00:45 -0700, Bart Schaefer wrote:
> If $SleepDuration can be < 1, don't you want
> 
> 	usleep $((SleepDuration * 1.0e+6))

I don't have a usleep(1) command.  I do have a BSD sleep(1) command
which takes fractional seconds, both on FreeBSD and MacOS, and the
Ubuntu systems I see have a sleep(1) which does the same, and appears to
be from GNU coreutils.

It appears that the GNU coreutils variant correctly parses
"3.000000000e-01" and sleeps for 0.3 seconds, instead of 3 seconds.

> The current behavior isn't problematic enough to have caused POSIX, bash,
> et al., to redefine sleep as a builtin, and it's not a problem I've ever
> encountered myself, but ...

I think POSIX still doesn't specify any support for non-integral
sleep(1) durations, right?

> If zsleep, then it could be a new module or be added to zsh/datetime.

Am reconsidering in light of this being purely a BSD sleep(1) bug.  Hrm.

Thanks,
-Phil



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