Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sleep $floatval
On Aug 31, 4:47pm, Phil Pennock wrote:
>
> So the float shows as 3.000000000e-01 which becomes a string, before
> being passed to the built-in sleep, which then does not parse that
> format as 0.3, nor show an error, but instead sleeps for 3 seconds
> without an error.
If $SleepDuration can be < 1, don't you want
usleep $((SleepDuration * 1.0e+6))
instead?
> What do folks think about sleep being a builtin, which can take
> arbitrary formats and avoid forking an extra process, just to delay?
I don't have any particular objection.
Incidentally, the manual actually recommends
zselect -t $((SleepDurationInSeconds * 100))
> Looking for a rough idea of whether people think the current behaviour
> is problematic enough to make it worth adding another builtin. And
> should it be sleep or zsleep, if so?
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 ...
It could be added as one or more subcommands of zsystem (the only one
currently is "flock"), e.g. "zsystem sleep $n", which allows you to do
"if zsystem supports sleep; then ... fi". Otherwise I'd say zsleep is
the best name for it, particularly if it magically converts floats into
fractional second sleeps.
If zsleep, then it could be a new module or be added to zsh/datetime.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author