[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can Bash do simple math?
From: |
Emanuele Torre |
Subject: |
Re: Can Bash do simple math? |
Date: |
Tue, 6 Aug 2024 15:11:26 +0200 |
User-agent: |
Mutt/2.2.13 (2024-03-09) |
On Tue, Aug 06, 2024 at 07:02:36AM -0400, Greg Wooledge wrote:
> On Tue, Aug 06, 2024 at 11:35:43 +0200, bash@blaklinten.xyz wrote:
> > My guess is that the $SECONDS variable was updated by Bash _after_ my
> > assignment but _before_ the printf command, resulting in a "erroneous"
> > value being printed. A kind of race condition, perhaps :)
>
> It certainly sounds like one. You might want to write a separate message
> to the bug-bash@gnu.org mailing list about it.
>
No, that is docuemented:
SECONDS
Each time this parameter is referenced, it expands to the number of
seconds since shell invocation. 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. The number
of seconds at shell invocation and the current time are always
determined by querying the system clock. If SECONDS is unset, it
loses its special properties, even if it is subsequently reset.
I've used it a bunch of times to time stuff.
o/
emanuele6
Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
- Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
- Re: Can Bash do simple math?, Greg Wooledge, 2024/08/06
- Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
- Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
- Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06
- Re: Can Bash do simple math?, Bash-help, 2024/08/06
- Re: Can Bash do simple math?, alex xmb sw ratchev, 2024/08/06