Subject: bug#7877: sleep 5 -4

From: Jim Meyering <[email-masked]>
Date: Tue, 25 Jan 2011 12:28:28 +0100

Paul Eggert wrote:
> OK, so it's late, but I can't resist:

You obviously need to, er... sleep.

> First, 'sleep' does accept one number that's negative
> in an IEEE-754 sense, namely, "sleep -- -0.0".
>
> Second, due to rounding error, 'sleep' does accept some
> numbers that are negative in a mathematical sense, e.g.,
> "sleep -- -1e1000" works.
>
> Third, there's nothing intrinsically wrong with 'sleep'
> accepting negative numbers.  All that POSIX
> requires is that 'sleep' must sleep for at *least* the
> amount of time specified.  So, if "sleep -- -1.0"
> is treated like "sleep 0", then it's conforming to
> that requirement of POSIX (obviously it doesn't
> conform to the other requirement that the operand be
> a nonnegative decimal integer; but it's a valid extension
> that is consistent with POSIX).

Maybe there is a use (albeit far-fetched) for negative numbers.
Let's say you want to sleep for 5 seconds less than a day.
Which would you prefer?
This:
    sleep -- 1d -5s
or this:
    sleep -- $((24*3600 - 5))s

> (Have I written enough to tempt you to extend 'sleep'
> to allow negative numbers?  :-)

I would accept the change.
Do you feel like writing it?