[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] sleep: allow ms suffix for milliseconds
From: |
Bernhard Voelker |
Subject: |
Re: [PATCH] sleep: allow ms suffix for milliseconds |
Date: |
Fri, 29 Nov 2019 23:02:42 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 |
On 2019-11-29 21:58, Kaz Kylheku (Coreutils) wrote:
> Sleeping for 15500 milliseconds is valid.
>
> But in any case, we can already do that with "sleep 15.500".
>
> The issue is that it's cumbersome to convert from 15500 to 15.500
> in a shell script.
This can easily be done ... with the shell's integer arithmetic
and due to the fact the GNU sleep adds all arguments to the final
nanosleep(2) time:
$ x=15500
$ sleep $((x/1000)) 0.$((x%1000))
I'm still not convinced - especially since the suggested suffix "ms"
is a 2-character suffix and therefore would change the 1-character
rule of suffix. I'm not sure if this could be a problem somewhere,
though.
If we want to support a suffix meaning a sub-second multiplier,
then - as the underlying system call is nanosleep(2) - I'd rather
go for using the single-char 'n' as suffix for nanoseconds.
Have a nice day,
Berny