GNU bug report logs - #7877
sleep takes undocumented hex args

Previous Next

Package: coreutils;

Reported by: jidanni <at> jidanni.org

Date: Fri, 21 Jan 2011 00:09:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #67 received at 7877 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 7877 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#7877: sleep 5 -4
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?




This bug report was last modified 14 years and 119 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.