[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SECONDS=0 does not reset SECONDS, or I'm missing something
From: |
Greg Wooledge |
Subject: |
Re: SECONDS=0 does not reset SECONDS, or I'm missing something |
Date: |
Fri, 5 Jun 2020 07:26:53 -0400 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Fri, Jun 05, 2020 at 12:01:08AM +0200, Andreas Kusalananda Kähäri wrote:
> Oh, I'm not expecting subsecond granularity! I'm expecting that
>
> SECONDS=0; sleep 0.5; echo $SECONDS
>
> always outputs a zero, which it does not do now if the system's clock
> rolls over to a new full second during the 0.5 seconds of sleep.
> It's just a bit odd to have the SECONDS parameter tick with the system
> time, which IMHO is not implied by the words "number of seconds since
> the assignment", that's all.
On the contrary, I am not surprised by it at all. I guess it comes down
to one's familiarity with different computing environments.
Writing the documentation to reflect that is something of a challenge,
as writing good documentation always is. Right now, it says:
SECONDS
Each time this parameter is referenced, the number of seconds
since shell invocation is returned. If a value is assigned to
SECONDS, the value returned upon subsequent references is the
number of seconds since the assignment plus the value assigned.
Perhaps something like this would work:
SECONDS
Expands to the difference between the current system time
(in seconds) and the system time (in seconds) at shell
invocation. If a value is assigned to SECONDS, the value
returned upon subsequent references is the value assigned
plus the difference between the current system time (in
seconds) and the system time (in seconds) upon assignment.
Feel free to use that, or tweak it, or discard it. I'm not thrilled
with the quadruple repetition of "system time (in seconds)" but I can't
think of a clearer way to express it at the moment.
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, (continued)
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Eli Schwartz, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, dan braun, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Andreas Kusalananda Kähäri, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Tim Visher, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Steve Amerige, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Eli Schwartz, 2020/06/04
Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Chet Ramey, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Tim Visher, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Andreas Kusalananda Kähäri, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something,
Greg Wooledge <=
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Chet Ramey, 2020/06/05
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Greg Wooledge, 2020/06/05
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Andreas Kusalananda Kähäri, 2020/06/05
Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Chet Ramey, 2020/06/05
Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Tim Visher, 2020/06/05
Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Mike Jonkmans, 2020/06/05