[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: |
Pier Paolo Grassi |
Subject: |
Re: SECONDS=0 does not reset SECONDS, or I'm missing something |
Date: |
Thu, 4 Jun 2020 16:18:07 +0200 |
sorry, you're right. Nonetheless the result is the same
SECONDS=0; E $SECONDS; sleep 0.9; E $SECONDS
0
1
maybe the behavior changed in more recent versions of zsh
Il giorno gio 4 giu 2020 alle ore 16:15 Andreas Kusalananda Kähäri <
andreas.kahari@abc.se> ha scritto:
> On Thu, Jun 04, 2020 at 04:06:06PM +0200, Pier Paolo Grassi wrote:
> > this is zsh 5.1.1 (a bit old):
> >
> > echo $SECONDS; sleep 0.5; echo $SECONDS
> > 1199
> > 1200
>
> This is slightly missing the point. Try setting SECONDS to 0 first, then
> sleep for 0.9 seconds. Try in both bash and zsh a few times.
>
> SECONDS=0; echo $SECONDS; sleep 0.9; echo $SECONDS
>
> In zsh, you'd get two zeroes (unless there's an unexpected pause
> somewhere).
> In bash you'd get a zero and a one most of the time.
>
> >
> > Il giorno gio 4 giu 2020 alle ore 15:59 Greg Wooledge <
> wooledg@eeg.ccf.org>
> > ha scritto:
> >
> > > On Thu, Jun 04, 2020 at 03:52:50PM +0200, Andreas Kusalananda Kähäri
> wrote:
> > > > I might have been a bit imprecise in describing my issue.
> > > >
> > > > Most of the time, removing the directories takes less than a second.
> > > > For these cases, I don't want to execute the sleep at all. Only
> when a
> > > > call to rm takes more than one second do I want to sleep.
> > >
> > > So, use "time rm ..." with the TIMEFORMAT variable set how you like.
> > > Capture the output of time into a variable (trickier than it sounds),
> > > and then sleep only if the variable does not match 0.* .
> > >
> > > See <https://mywiki.wooledge.org/BashFAQ/032> for help capturing
> time's
> > > output.
> > >
> > >
>
> --
> Andreas (Kusalananda) Kähäri
> SciLifeLab, NBIS, ICM
> Uppsala University, Sweden
>
> .
>
- 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, Steve Amerige, 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, Andreas Kusalananda Kähäri, 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, Pier Paolo Grassi, 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, 2020/06/04
- Re: SECONDS=0 does not reset SECONDS, or I'm missing something, Pier Paolo Grassi, 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,
Pier Paolo Grassi <=
- 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