[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can Bash do simple math?
From: |
Greg Wooledge |
Subject: |
Re: Can Bash do simple math? |
Date: |
Tue, 6 Aug 2024 09:16:44 -0400 |
On Tue, Aug 06, 2024 at 15:11:26 +0200, Emanuele Torre wrote:
> 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.
Ahhh, sorry, I forgot you have to explicitly *unset* it to turn off the
special behavior. I was thinking that just assigning a value to it would
do that.
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
Re: Can Bash do simple math?, Greg Wooledge, 2024/08/06